且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我无法使用LWP :: UserAgent连接到任何HTTPS站点

更新时间:2023-02-24 11:57:42

请确保您至少使用版本6.06的LWP :: UserAgent和版本6.06 LWP ::协议:: HTTPS。之前的任何版本都没有对https代理的适当支持,至少在使用IO :: Socket :: SSL作为底层SSL库时是这样。

Please make sure, that you use at least version 6.06 of LWP::UserAgent and version 6.06 of LWP::Protocol::https. Any versions before do not have proper support for https proxy, at least not when using IO::Socket::SSL as the underlying SSL library.

要获取正在运行的版本:

To get the versions you are running:

use LWP::UserAgent;
use LWP::Protocol::https;
print "LWP::UserAgent: ".LWP::UserAgent->VERSION,"\n";
print "LWP::Protocol::https: ".LWP::Protocol::https->VERSION,"\n";

如果你使用的东西少于所需的版本升级。虽然LWP :: UserAgent很容易,但cpan默认情况下可能无法安装最新版本的LWP :: Protocol :: https,请参阅 http://www.nntp.perl.org/group/perl.libwww/2014/05/msg7718.html 。在这种情况下,您必须明确地从 http://search.cpan .org / ~mschilli / LWP-Protocol-https-6.06 /

If you use anything less than the required versions upgrade. While this is easy for LWP::UserAgent, cpan might not install the newest version of LWP::Protocol::https by default, see http://www.nntp.perl.org/group/perl.libwww/2014/05/msg7718.html. In this case you have to get it explicitly from http://search.cpan.org/~mschilli/LWP-Protocol-https-6.06/.

如果您使用的是最近的Debian系统或Ubuntu> = 14.04,您仍然会有版本6.04的LWP :: Protocol :: https,但这包括已经正确的https代理支持的必要补丁。

If you are on a recent Debian system or Ubuntu >=14.04 you will still have version 6.04 of LWP::Protocol::https, but this includes already the necessary patches for proper https proxy support.

另一种选择是使用旧网:: SSL / Crypt :: SSLeay后端用于LWP,但我建议反对它,因为它没有实现所有必要的证书检查,因此很容易对其进行中间人攻击。

The other alternative would be to use the old Net::SSL/Crypt::SSLeay backend for LWP, but I advice against it, because it does not implement all necessary certificate checks and thus mounting a man-in-the-middle attack against it is easy.