尝试使用 LWP 连接到特定 https 网站时出现以下错误:
LWP::Protocol::https::Socket: SSL connect attempt failed with unknown errorerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at /usr/local/share/perl/5.14.2/LWP/Protocol/http.pm line 51.
我尝试使用 wget 并得到:
ERROR: cannot verify [domain]'s certificate, issued by `/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com, Inc./OU=http://certificates.godaddy.com/repository/CN=Go Daddy Secure Certification Authority/serialNumber=********':
Unable to locally verify the issuer's authority.
我四处搜索,发现我可能必须安装 godaddy root ca 证书。我想出了如何做到这一点(下载证书,放入 /usr/share/ca-certificates 并运行 update-ca-certificates)。我还学习了如何在这个过程中使用 openssl s_client。
现在证书已安装,wget 可以工作,但 LWP 仍然失败并出现同样的错误,openssl s_client 也是如此:
# openssl s_client -connect [domain]:443
CONNECTED(00000003)
depth=0 O = [domain], OU = Domain Control Validated, CN = [domain]
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 O = [domain], OU = Domain Control Validated, CN = [domain]
verify error:num=27:certificate not trusted
verify return:1
depth=0 O = [domain], OU = Domain Control Validated, CN = [domain]
verify error:num=21:unable to verify the first certificate
verify return:1
我不知道下一步该去哪里让它工作。有什么建议么?
编辑:已 解决这是一个简单的脚本,描述了 mikew 的建议之后的工作:
#!/usr/bin/perl
use LWP::UserAgent;
$URL="[domain]";
my $ua = LWP::UserAgent->new(ssl_opts => { SSL_ca_path=>'/etc/ssl/certs'});
my $response = $ua->get($URL);