如何忽略perl中的“证书验证失败”错误?

时间:2011-07-22 19:25:47

标签: perl https ssl-certificate

我想访问无法验证证书的网站。我正在使用WWW :: Mechanize get请求。那么如何忽略这一点并继续连接到网站?

2 个答案:

答案 0 :(得分:24)

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
});

如果IO :: Socket :: SSL早于1.79,请参阅PERL_LWP_SSL_VERIFY_HOSTNAME

答案 1 :(得分:4)

my $mech = WWW::Mechanize->new( 'ssl_opts' => { 'verify_hostname' => 0 } );