I am trying to create a script that simply just connect to a website. However, for some reason it will not connect to anything that is using HTTPS.
We have a proxy enabled here. However, I believe the proxy is not the problem, because if I were to connect to an HTTPS inside the network that does not tunnel through a proxy it still fails.
If I were to run this program on any site that is not using HTTPS, I can get through and the script works as intended.
What I'm wondering is what could possible by blocking the script from connecting to any SSL secured sites.
Here is the code that I wrote:
$ENV{HTTPS_DEBUG} = 1;
my $ua = LWP::UserAgent->new( keep_alive => 1);
$ua->agent('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36');
my $pac = HTTP::ProxyPAC->new( URI->new("http://pacfilelocation:8080/pac_file.pac") );
my $res = $pac->find_proxy("https://www.google.com");
if ($res->direct) {
print "No Proxy Needed\n";
} elsif ($res->proxy) {
print "Proxy: " . $res->proxy . "\n";
$ENV{HTTPS_PROXY} = $res->proxy;
$ENV{HTTP_PROXY} = $res->proxy;
$ua->env_proxy;
}
my $req = new HTTP::Request('GET', 'https://www.google.com/');
$req->header('Accept' => 'text/html');
$req->header('Host', 'www.google.com');
my $res2 = $ua->request($req);
if ( $res2->is_success ) {
print $res2->decoded_content;
} else {
print "Error: " . $res2->status_line . "\n";
}
The HTTPS_DEBUG feature for some reason does not output the debug, which makes this all the more hard to solve.
When running the script I get a generic error:
Error: 500 Can't connect to www.google.com:443
Any help would be great!