Question

Here is my code:

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

I am getting this error:

`SSL peer certificate was not ok`
Was it helpful?

Solution

LWP::Curl doesn't accept CURLOPT_SSL_VERIFYHOST/CURLOPT_SSL_VERIFYPEER parameters for it's constructor!

Use LWP::Protocol::Net::Curl instead:

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

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

Note that LWP::Protocol::Net::Curl alters the default LWP::UserAgent behavior, so you still use $ua = LWP::UserAgent->new, while it uses libcurl internally.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top