我正在尝试访问一个简单的HelloWorld .NET Web服务.我收到的错误似乎与Perl或SOAP :: lite无法验证SSL证书有关.
虽然它看起来像是返回了500的代码,但是我创建了一个能够很好地调用web方法的Java客户端,所以我认为问题不在Web服务端.
任何人都能指出我正确的方向,我将如何工作?
脚本:
#!/usr/bin/perluse 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/plainClIEnt-Date: Tue,12 Feb 2013 16:40:28 GMTClIEnt-Warning: Internal responseCan't connect to www.mydomain.com:443 (certificate verify Failed)You can disable hostname check by setting environment variable PERL_LWP_SSL_VERIFY_HOSTname=0LWP::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解决方法 以下是如何安全地工作,即不禁用SSL主机名检查.
如果您正在与具有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.
总结以上是内存溢出为你收集整理的Perl:无法使用SSL访问Web服务全部内容,希望文章能够帮你解决Perl:无法使用SSL访问Web服务所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)