5

I'm receiving a certificate error when trying to send a POST message to a website.

The error I'm receiving:

LWP::Protocol::https::Socket: SSL connect attempt failed error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at /usr/lib/perl5/site_perl/5.8.8/LWP/Protocol/http.pm line 49

The code that I'm using is:

my $webpage = "";

my $ua = LWP::UserAgent->new( );
$ua->agent('Mozilla');

$webpage = "https://mysite:444/myapp/app.aspx";


my $msg = 'An XML Message';

my $req = POST $webpage, 
                 Content_Type => 'text/xml',
                 Content => $msg;

So far I've tried a few "fixes" that I've found online:

Tried disabling verify hostname through environment variable: $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;

Tried disabling verify hostname through ssl_opts:

my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, );

Tried using the Mozilla CA and setting HTTPS_CA_FILE to /usr/lib/perl5/site_perl/5.8.8/Mozilla/CA/cacert.pem?

At this point I'm out of options to try so I'm hoping someone has run into this problem before and can provide assistance.

Rubix Rechvin
  • 571
  • 3
  • 16
  • Please indicate which versions of the libraries you are using, i.e. perl -MLWP::UserAgent -e 'warn LWP::UserAgent->VERSION'` and the same for LWP::Protocol::https and IO::Socket::SSL. Also check if the access is successful with a normal browser or if it complains too about invalid certificate. – Steffen Ullrich Dec 29 '14 at 19:29
  • Wow! I think you hit it on the nail! My LWP::UserAgent and IO::Socket::SSL are at the latest version, but the LWP::Protocol::https library wasn't even installed. In trying to install it though, I'm getting hung up at http-nb.t 1/14 Have you encountered this before? – Rubix Rechvin Dec 29 '14 at 19:51
  • 1
    If LWP::UserAgent was installed as the newest version than you would not be able to do any HTTPS requests without having LWP::Protocol::https installed and thus you should not get this SSL related error message about certificate verification problems. And no, I did not get the errors in the test but please note that Perl 5.8.8. is a way old and totally unsupported version (and not even the last of the 5.8.x series) and there might be some problems nobody will fix. – Steffen Ullrich Dec 29 '14 at 20:14
  • Just saw that too, upgrading to perl 5.21.7 now. Hopefully this fixes my issues. Thanks! – Rubix Rechvin Dec 29 '14 at 20:32

1 Answers1

2

It's just a typo, use "verify_hostname" without the "s":

my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, );

Ben Grimm
  • 4,316
  • 2
  • 15
  • 24