http://www.perlmonks.org?node_id=444729

mickey has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I'm trying to access an HTTPS website from behind a proxy server using LWP::UserAgent and Crypt::SSLeay.

My test script looks like this:

#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; my $url = $ARGV[0]; my $proxy_ip = 'https-proxy.example.com'; my $proxy_port = 80; $ENV{'HTTPS_PROXY'} = "$proxy_ip:$proxy_port"; $ENV{'HTTPS_DEBUG'} = 1; my $ua = LWP::UserAgent->new; print "Connecting to $url ...\n"; my $response = $ua->get( $url ); $response->is_success or die "Failed to GET '$url': ", $response->status_line; print $response->as_string;

This returns a "403 Forbidden" error from the proxy. When I watch the transaction with Ethereal, though, I get the following:

CONNECT remote.server.com:443 HTTP/1.0 HTTP/1.0 200 Connection established CONNECT https-proxy.example.com:80 HTTP/1.0 HTTP/1.0 403 Forbidden

It looks like the first CONNECT request is working fine, but LWP::UserAgent is actually sending two CONNECT requests when I've only asked it to send one, and the second request is failing because it's trying to connect directly to the proxy rather than to the remote server.

Any thoughts on why this would be happening?

Thanks.