I've been completely stymied on a problem connecting to a HTTPS site via our
proxy server. I've tried dozens of different work arounds I found on the
web and none seem to work and I think I've localized the problem down to an
environment variable not loading.
Here's the small script I'm running to test this out:
#!/usr/bin/perl
use strict;
$ENV{HTTPS_PROXY}='http://<
proxy>/';
use LWP::UserAgent;
use HTTP::Request::Common;
use Crypt::SSLeay;
my $ua = new LWP::UserAgent;
$ua->cookie_jar();
$ua->protocols_allowed(['http','https']);
$ua->env_proxy();
my $url = 'https://www.redhat.com';
my $res = $ua->get($url);
if($res->is_success)
{
print $res->as_string;
}
else
{
print "FAILED: ".$res->status_line;
print "\n\n";
print $res->as_string;
}
If I include the line *$ua->env_proxy()* I get a '400 - Bad Request' error
from the proxy server. The reason for this is because it is sending a GET
call instead of a CONNECT call. This supposedly works on apache servers but
anywhere else, you need to have Crypt::SSLeay take over and do the proper
CONNECT call. The instructions on this are to set the
*$ENV{HTTPS_PROXY}*variable as I have done and remove the call to
*$ua->env_proxy()*. This should then use Crypt::SSLeay and do a CONNECT.
When I make this change, I get a 500 error because it can't find the proxy.
I have also tried setting my Windows environment variable for HTTPS_PROXY
and proved it is set but the script still doesn't see it. I can connect to
https sites without an issue via FireFox. Is there something simple I'm
missing to force the script to use the environment variable HTTPS_PROXY?
any help would be much appreciated,
regards,
Mark
--
Mark Denzel
Black Belt
Converged Computing Group
Motorola Mobility
w/m: 815-531-7621