ssl - Perl LWP::UserAgent cannot connect to HTTPS -
i have script used content google. work well, doesn't. found post on stackexchange , upgrade library version, still doesn't work: i cannot connect https site using lwp::useragent
i have connectivity linux machine (telnet googleapis.com 443 works 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"; $ua = lwp::useragent->new(ssl_opts => { verify_hostname => 0 }); $ua->agent('mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/35.0.1916.153 safari/537.36'); $ua->timeout(10); $ua->env_proxy; $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;
the error: 500 can't connect www.googleapis.com:443
any idea why happen?
in cases, need force sslv3
my $ua = lwp::useragent->new(ssl_opts => { verify_hostname => 0, ssl_version => 'sslv3' });
Comments
Post a Comment