我得到了以下代码,我认为它不会验证服务器证书,但它仍然会:
500 Can't connect to 10.0.0.9:443 (certificate verify failed)
不确定原因。以下是代码段:
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;
my $req = HTTP::Request->new(POST => 'https://10.0.0.9/test1234');
$ua->ssl_opts( verify_hostnames => 0 );
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
print $res->content;
}
else {
print $res->status_line, "\n";
}
有什么想法吗?谢谢!