Perl LWP :: UserAgent cannot connect to HTTPS

I have a script that is used to receive content from Google. It works very well, but now it is not. I found a stackexchange post and I am updating the library version, but it still does not work: I cannot connect to any HTTPS site using LWP :: UserAgent

I have a connection with a Linux machine (telnet googleapis.com 443 works very well).

#!/usr/bin/perl


use CGI 'param';
use CGI::Carp 'fatalsToBrowser';
use DBI;
    require LWP::UserAgent;
    use LWP::Protocol::https;
    use URI::Escape;
    $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
    $access_token='xxx';
    print "LWP::UserAgent: ".LWP::UserAgent->VERSION,"\n";
    print "LWP::Protocol::https: ".LWP::Protocol::https->VERSION,"\n";
    $url="https://www.googleapis.com/oauth2/v1/userinfo?access_token=$access_token";
        my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
$ua->agent('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36');
        $ua->timeout(10);
        $ua->env_proxy;
        my $response = $ua->get("$url");
        if ($response->is_success) {
        print "Am adus cu succes contul de la google";
            $text=$response->decoded_content;  # or whatever
        }
        else {
            print "Response error:".$response->status_line."\n";

        }


1;

Error: 500 Cannot connect to www.googleapis.com:443

Any idea why this is happening all of a sudden?

+4
source share
2 answers

In some cases you need to force SSLv3

my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0, SSL_version => 'SSLv3' });
+2
source

LWP::Protocol::https CPAN perl-LWP-Protocol-https.

, CentOS, root yum install perl-LWP-Protocol-https

https- , , .

0

All Articles