我正在尝试使用 perl 脚本从运行 3rd 方软件的本地计算机中检索信息。我可以用网络浏览器查看它,但我需要自动化它。问题是它似乎不喜欢安装软件时创建的 SSL 证书。
我说没问题。我只会告诉 LWP:UserAgent 忽略证书。嗯...同样的错误。
这是我正在使用的测试脚本...
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new( 'ssl_opts' => { 'verify_hostname' => 0 } );
my $response = $ua->get( 'https://192.168.1.50' );
print "\n\n";
if ( defined( $response ) ) {
print $response->as_string;
}
else {
print "No response object created.";
}
print "\n";
...这是我得到的回应...
500 Can't connect to 192.168.1.50:443 (certificate verify failed)
Content-Type: text/plain
Client-Date: Tue, 05 Nov 2013 16:42:53 GMT
Client-Warning: Internal response
Can't connect to 192.168.1.50:443 (certificate verify failed)
LWP::Protocol::https::Socket: SSL connect attempt failed with unknown error error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at /usr/local/share/perl5/LWP/Protocol/http.pm line 51.
根据我在文档中阅读的内容以及在各种论坛上看到的建议,将“verify_hostname”设置为错误值会导致它忽略无效证书。
关于我所缺少的任何建议?