1

have a problem when i try to connect with web service that have certification , username and password as credentials

500 proxy connect failed: PROXY ERROR HEADER, could be non-SSL URL

My code is below:

use LWP::Debug qw(+);
use HTTP::Request::Common;
use Crypt::SSLeay;
use HTTP::Headers;
use HTTP::Request;
use LWP;
$url = "https://ip:port/service";
my $ua = new LWP::UserAgent;
$ENV{HTTPS_DEBUG}          = 1;
$ENV{HTTPS_PROXY}          = 'https://ip:port';
$ENV{HTTPS_PROXY_USERNAME} = "username";
$ENV{HTTPS_PROXY_PASSWORD} = "password";
$ENV{HTTPS_CA_FILE}        = 'cert.crt';
$ENV{HTTPS_CA_DIR}         = '/passof/cert/';
$ENV{HTTPS_VERSION}        = '3';

my $message = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/e
nvelope/" xmlns:aud="https://ip:port/">
   <soapenv:Body>
      any /////
   </soapenv:Body>
</soapenv:Envelope>';

my $userAgent = LWP::UserAgent->new();
my $request = HTTP::Request->new( GET => 'https://ip:port/service' );
$request->header( SOAPAction => '"https://ip:port/action"' );
$request->content($message);
$request->content_type("text/xml; charset=utf-8");
my $response = $userAgent->request($request);
if ( $response->code == 200 ) {
    print $response->as_string;
}
Miller
  • 34,962
  • 4
  • 39
  • 60
  • It looks like you specify something as a proxy which is not a proxy. And please don't try to enforce use of Crypt::SSLeay, this module is old and insecure. Please use the default IO::Socket::SSL. – Steffen Ullrich Sep 07 '14 at 12:16
  • how can i use IO::Socket::SSL – Mohamed Elshafey Sep 10 '14 at 09:41
  • If you have a recent enough version of LWP (see http://stackoverflow.com/a/25708373/3081018) it will be used automatically if it is installed, just don't include Crypt::SSLeay. To check if it is installed call `perl -MIO::Socket::SSL -e ''` - if it does not throw an error it is installed. If it is not installed install it like any other Perl module (how to install prepackaged perl modules depend on your OS). – Steffen Ullrich Sep 10 '14 at 12:03

0 Answers0