我正在尝试访问一个简单的HelloWorld .NET Web服务.我收到的错误似乎与Perl或SOAP :: Lite无法验证SSL证书有关.
虽然它看起来像是返回了500的代码,但是我创建了一个能够很好地调用web方法的Java客户端,所以我认为问题不在Web服务端.
任何人都能指出我正确的方向,我将如何工作?
脚本:
#!/usr/bin/perl use SOAP::Lite 'trace','debug'; $api_ns = "https://www.mydomain.com/edgedev/"; $api_url = "https://www.mydomain.com/edgedev/ws.asmx"; $action = "HelloWorld"; my $soap = SOAP::Lite -> readable(1) -> ns($api_ns,'tns') -> proxy($api_url) -> on_action(sub { return "\"$action\""}); print $soap->HelloWorld()->result;
结果
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="https://www.mydomain.com/edgedev/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <tns:HelloWorld xsi:nil="true" /> </soap:Body> </soap:Envelope> SOAP::Transport::HTTP::Client::send_receive: 500 Can't connect to www.mydomain.com:443 (certificate verify Failed) Content-Type: text/plain Client-Date: Tue,12 Feb 2013 16:40:28 GMT Client-Warning: Internal response Can't connect to www.mydomain.com:443 (certificate verify Failed) You can disable hostname check by setting environment variable PERL_LWP_SSL_VERIFY_HOSTNAME=0 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/vendor_perl/5.10.0/LWP/Protocol/http.pm line 57. 500 Can't connect to www.mydomain.com:443 (certificate verify Failed) at ./soaptest.pl line 15
如果您正在与具有CA签名证书的公共系统进行通信,则需要将LWP指向您的分发的根证书集合.在基于Debian的系统(Ubuntu等)下,它保存在/ etc / ssl / certs /下.
BEGIN { $ENV{HTTPS_CA_DIR} = '/etc/ssl/certs' }
如果您使用自签名证书与自己的服务器通信,则可以在客户端上保存该证书的副本,并将脚本指向该特定文件.
BEGIN { $ENV{HTTPS_CA_FILE} = '/path/to/my/server-certificate.crt' }
您可以在运行脚本之前在环境中设置它们(例如,从shell导出它们),或者可以将设置直接应用于UserAgent对象.有关详细信息,请参阅LWP::UserAgent documentation;搜索ssl_opts.