gpt4 book ai didi

xml - LWP::UserAgent 将 XML 发布到安全服务器...证书问题

转载 作者:太空宇宙 更新时间:2023-11-03 13:04:38 25 4
gpt4 key购买 nike

我正在使用 LWP::UserAgent 将 XML 数据发送到远程服务器。远程 URL 是 https,他们向我发送了一个 .crt 文件以安装在我的服务器上。

当我尝试连接到他们的服务器时,我收到以下消息:

An Error Occurred

500 Can't connect to previewtest.clverify.com:443 (certificate verify failed) 500 Can't connect to previewtest.clverify.com:443 (certificate verify failed) Content-Type: text/plain Client-Date: Wed, 25 Jan 2012 05:11:24 GMT Client-Warning: Internal response Can't connect to previewtest.clverify.com:443 (certificate verify failed) LWP::Protocol::https::Socket: SSL connect attempt failed with unknown errorerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at /usr/lib/perl5/site_perl/5.8.8/LWP/Protocol/http.pm line 51.

我如何在我的服务器上正确引用 SSL 证书并将其发送给他们的服务器?

代码如下:

sub ConsumerInfo {
my $cid = shift;

my $response = undef;
my $sendXML = &Create_ConsumerInfo_Request($cid);
if ($sendXML) {
&DoXMLUpload($sendXML);

my $browser = LWP::UserAgent->new(agent => 'perl post');
$browser->credentials('sumURL:443','sumRealm','sumUserID'=>'sumPassword');
$response = $browser->request(POST 'sumFullURL',
Content_Type => 'text/xml',
Content => $sendXML);
print "Content-type:text/html\n\n";
print $response->error_as_HTML unless $response->is_success;
print $response->as_string;
} else {
&ErrorMsg("No XML Code Was Found.");
exit;
}
# ===============================================================
# Need to insert parser in here to convert this into an array.
# ===============================================================
return $response;
}

现在...假设发送给我的证书位于/usr/bin/some_dir/DigiCertCA.crt。

我如何设置它以在调用服务器时检查我的证书?

最佳答案

首先,我会尝试将 my $browser 行更改为:

my $browser = LWP::UserAgent->new(
agent => 'perl post',
ssl_opts => {
verify_hostname => 1,
SSL_ca_path => '/usr/bin/some_dir',
},
);

关于xml - LWP::UserAgent 将 XML 发布到安全服务器...证书问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8998254/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com