6

我在使用 HTTPS 站点的 perl 屏幕截图时遇到问题。在调试中,我运行了以下命令:

print $res->headers_as_string;

在输出中,我有以下行:

Client-SSL-Warning: Peer certificate not verified

有没有办法我可以自动接受这个证书,或者这不是问题吗?

#!/usr/bin/perl 
use LWP::UserAgent; 
use Crypt::SSLeay::CTX; 
use Crypt::SSLeay::Conn; 
use Crypt::SSLeay::X509; 
use LWP::Simple qw(get);

my $ua  = LWP::UserAgent->new; 
my $req = HTTP::Request->new(GET => 'https://vzw-cat.sun4.lightsurf.net/vzwcampaignadmin/');
my $res = $ua->request($req);

print $res->headers_as_string;

输出:

Cache-Control: no-cache
Connection: close
Date: Tue, 01 Jun 2010 19:28:08 GMT
Pragma: No-cache
Server: Apache
Content-Type: text/html
Expires: Wed, 31 Dec 1969 16:00:00 PST
Client-Date: Tue, 01 Jun 2010 19:28:09 GMT
Client-Peer: 64.152.68.114:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /O=VeriSign Trust Network/OU=VeriSign, Inc./OU=VeriSign International Server CA - Class 3/OU=www.verisign.com/CPS Incorp.by Ref. LIABILITY LTD.(c)97 VeriSign
Client-SSL-Cert-Subject: /C=US/ST=Massachusetts/L=Boston/O=verizon wireless/OU=TERMS OF USE AT WWW.VERISIGN.COM/RPA (C)00/CN=PSMSADMIN.VZW.COM
Client-SSL-Cipher: DHE-RSA-AES256-SHA
Client-SSL-Warning: Peer certificate not verified
Client-Transfer-Encoding: chunked
Link: <css/vtext_style.css>; rel="stylesheet"; type="text/css"
Set-Cookie: JSESSIONID=DE6C99EA2F3DD1D4DF31456B94F16C90.vz3; Path=/vzwcampaignadmin; Secure
Title: Verizon Wireless - Campaign Administrator

更新:我添加了

$ENV{HTTPS_CA_FILE}   = 'certs/PSMSADMIN.VZW.COM';
$ENV{HTTPS_CA_DIR}    = 'certs/';

如下所示。我还打开了调试:

$ENV{HTTPS_DEBUG} = 1;

这是我的输出:

SSL_connect:before/connect initialization
SSL_connect:SSLv3 write client hello A
SSL_connect:SSLv3 read server hello A
SSL3 alert write:fatal:bad certificate
SSL_connect:error in SSLv3 read server certificate B
SSL_connect:before/connect initialization
SSL_connect:SSLv2 write client hello A
SSL_connect:error in SSLv2 read server hello B
content: 500 SSL negotiation failed: error:1407E086:SSL routines:SSL2_SET_CERTIFICATE:certificate verify failed

我试图忽略失败,但问题是这是页面上现在唯一的东西,所以没有登录表单或任何东西。

4

1 回答 1

4

据我所知,这只是一个警告。该站点上的证书与域不匹配,因此 perl (理所当然地)抱怨它。如果您真的像这样打开对等证书验证:

# CA cert peer verification
$ENV{HTTPS_CA_FILE}   = 'certs/ca-bundle.crt';
$ENV{HTTPS_CA_DIR}    = 'certs/';

你会得到这个作为你的输出:

Content-Type: text/plain
Client-Date: Tue, 01 Jun 2010 19:32:51 GMT
Client-Warning: Internal response
500 SSL negotiation failed: error:1407E086:SSL
      routines:SSL2_SET_CERTIFICATE:certificate verify failed
Content-Type: text/plain
Client-Date: Tue, 01 Jun 2010 19:32:51 GMT
Client-Warning: Internal response

有一个名为get_peer_verifyin Net::SSLCrypt::SSLeay提供)的方法,它返回是否需要对等验证。我相信它是在 2001 年左右添加的,以便隐藏此消息。这个 2002 年的补丁声称在不需要对等验证时关闭警告,但我认为它从未应用过。

所以简而言之,除非您打算进行验证,否则您可能会忽略警告,在这种情况下,我会说将根证书添加到您的CA_DIRand CA_FILE. 但是由于证书的域与服务器的域不匹配,我什至不确定这是否会有所帮助。

于 2010-06-01T19:44:19.173 回答