perl 500代理连接失败:PROXY ERROR HEADER,可能是非SSL URL

时间:2014-09-07 12:01:21

标签: perl ssl proxy lwp lwp-useragent

当我尝试连接具有证书,用户名和密码作为凭据的Web服务时,

出现问题

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

我的代码如下:

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;
}

0 个答案:

没有答案