大佬教程收集整理的这篇文章主要介绍了perl – 错误:500无法连接到example.com:443(证书验证失败),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
use LWP::UserAgent; use http::request::Common qw(POST); use http::Cookies; $URL="https://example.com/my.plicy"; $UA = LWP::UserAgent->new(); $UA->ssl_opts( verify_hostnames => 0 ); #UA->ssl_opts( SSL_ca_file => Mozilla::CA::SSL_ca_file() ); $req =http::request::Common::POST("$URL",Content_type=>'form-data',Content =>[ 'username'=>'111','password'=>'2222','vhost'=>'standard' ] ); $req->header('Cookie' =>q(Tin=287000; LastMRH_Session=439960f5; MRHSession=78c9c47291c1fcedae166121439960f5)); $resp=$UA->request($req); if( ($resp->code() >= 200) && ($resp->code() <400) ) { print $resp->decoded_content; }else{ print "Error: ". $resp->status_line. "\n"; }
问题是我没有提供真正的证书,因为该站点处于开发阶段,并且使用了localhost的证书……浏览器不识别它.
有没有办法绕过验证?并避免错误?
更新:
我改变了我的代码.添加了另一个库并添加了此功能:
use CACertOrg::CA; $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; $UA->ssl_opts( verify_hostnames => 0,SSL_ca_file => CACertOrg::CA::SSL_ca_file() );
现在我明白了:
在C:/Perl/lib/LWP/Protocol/http.pm第31行.
所以我将选项更改为:
$UA->ssl_opts( SSL_verify_mode => 'SSL_VERIFY_NONE',verify_hostnames => 0,SSL_ca_file => CACertOrg::CA::SSL_ca_file() );
我没有得到任何打印..虽然我没有得到错误..这是一个好兆头吗?
以上是大佬教程为你收集整理的perl – 错误:500无法连接到example.com:443(证书验证失败)全部内容,希望文章能够帮你解决perl – 错误:500无法连接到example.com:443(证书验证失败)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。