1

I seem to have an odd difference in LWP::UserAgent on Ubuntu and CentOS.

On Ubuntu (14.04.1 with LWP::UserAgent 6.05), if I try to connect to a domain with a self-signed certificate, I get this error message with a 500 error code:

"Can't connect to my.test-domain.com:443 (certificate verify failed)"

That's good. I can see exactly what's wrong - a certificate issue. But on CentOS 7 (also with LWP::UserAgent 6.05) I just get this:

"Can't connect to my.test-domain.com:443".

That's less informative, and as such gives me a problem! Does anyone know how I can kick LWP on CentOS to get the "certificate verify failed" message? Here is the script I test with:

#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
my $url='https://my.test-domain.com/';
my $browser= LWP::UserAgent->new();
my $tryHEAD=$browser->head($url);
my $responseCode=$tryHEAD->code();
if($tryHEAD->code()==200  ) {    print "OK\n"; }
else {    print $tryHEAD->code().' '.$tryHEAD->message()."\n"; }
RichardM
  • 13
  • 2
  • See http://stackoverflow.com/questions/19397346/error-500-cant-connect-to-example-com443-certificate-verify-failed – AKHolland Jan 10 '15 at 18:25
  • That's probably due to different versions of IO::Socket::SSL used. Please check with `perl -MIO::Socket::SSL -e 'warn IO::Socket::SSL->VERSION'` – Steffen Ullrich Jan 12 '15 at 16:12
  • @SteffenUllrich - Thanks, I thought that was going to be it! Ubuntu had IO::Socket::SSL 1.965, CentOS had 1.94. But no. I upgraded both, and I still have the same issue (both are now 2.09) – RichardM Jan 13 '15 at 15:07

1 Answers1

1

It seems related to the version of IO::Socket::IP (which is automatically used by IO::Socket::SSL). Without IO::Socket::IP or with version 0.31 (and probably later) it works as intended while with version 0.25 (Ubuntu 14.04) it does not. This is probably related to changes in the handling of connect in version 0.30,0.31.

Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172
  • Excellent. Thanks @SteffenUllrich. On CentOS 7 I had IO::Socket::IP 0.21. Upgrading to 0.36 did the trick. – RichardM Jan 18 '15 at 11:38