Perl LWP卷曲错误:'SSL对等证书不正常'

时间:2013-03-26 17:03:19

标签: perl curl lwp

这是我的代码:

my $lwpcurl = LWP::Curl->new(CURLOPT_SSL_VERIFYHOST => 0,CURLOPT_SSL_VERIFYPEER=>0);
my $content;
$content = $lwpcurl->get($url);

我收到此错误:

`SSL peer certificate was not ok`

1 个答案:

答案 0 :(得分:1)

LWP::Curl不接受CURLOPT_SSL_VERIFYHOST / CURLOPT_SSL_VERIFYPEER参数作为其构造函数!

改为使用LWP::Protocol::Net::Curl

use LWP::Protocol::Net::Curl ssl_verifyhost => 0, ssl_verifypeer => 0;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new;
my $content = $ua->get($url);

请注意,LWP :: Protocol :: Net :: Curl会改变默认的LWP :: UserAgent行为,因此您仍然使用$ua = LWP::UserAgent->new,而内部使用libcurl