Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore 'Certificate Verify Failed' error in perl?

I want to access a website where the certificate cannot be verified. I'm using WWW::Mechanize get request. So how would go about ignoring this and continues to connect to the website?

like image 651
Shahab Avatar asked Jul 22 '11 19:07

Shahab


People also ask

How do I bypass a validation certificate?

To bypass SSL certificate validation for local and test servers, you can pass the -k or --insecure option to the Curl command. This option explicitly tells Curl to perform "insecure" SSL connections and file transfers. Curl will ignore any security warnings about an invalid SSL certificate and accept it as valid.

What does certificate verify failed mean?

Summary. The Ruby OpenSSL error certificate verify failed means your code can't verify that the SSL certificate of the website or API you're connecting to is the real one. It's important to solve this issue correctly to keep your communication secure.


1 Answers

use IO::Socket::SSL qw();
use WWW::Mechanize qw();
my $mech = WWW::Mechanize->new(ssl_opts => {
    SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE,
    verify_hostname => 0, # this key is likely going to be removed in future LWP >6.04
});

With IO::Socket::SSL earlier than 1.79, see PERL_LWP_SSL_VERIFY_HOSTNAME.

like image 57
daxim Avatar answered Sep 20 '22 18:09

daxim