in reply to LWP not working with HTTPS protocol (SOLVED)

Just FYI, I've noticed that the first test of LWP::Protocol::https fails because sometimes, when it tries to connect to the Apache Software Foundation, it connects ok; sometimes, it can't make a connection. For example, I installed it on 5.8.8 with no problems. A couple of hours later, I tried it on 5.16.0, but it couldn't connect. It seems the site is up and down frequently.

The modules are installed, so they should just work. I think that LWP needs to be told to do https, at least in this situation:
#!/usr/bin/perl -l use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, protocols_allowed => ['https'], ); my $req = HTTP::Request->new( GET => '', ); my $res = $ua->request($req); print $res->code;

Replies are listed 'Best First'.
Re^2: LWP not working with HTTPS protocol
by noxxi (Pilgrim) on May 03, 2015 at 12:45 UTC
    Please don't disable hostname validation, at least not with any code used in production. This makes you vulnerable to man-in-the-middle attacks.