Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I just spent several hours debugging some code using LWP::UserAgent. The code could be reduced to this:

use strict; use warnings; use LWP::UserAgent; my $URL = 'https://myhost.local/'; my $ua = LWP::UserAgent->new; $ua->ssl_opts( verify_hostname => 0 ); my $response = $ua->get($URL); if ($response->is_success) { print $response->decoded_content; # or whatever } else { die $response->status_line; }

So pretty much a copy&paste from the LWP::UserAgent docs.

The error message I got was:

Can't connect to myhost.local:443\n\n 500 Can't connect to myhost.local:443 at line 15.

After some debugging, strace finally showed me an ENOENT for an SSL CA file, which nudged me into the right direction.

So, my questions are:

  • Why does a missing CA file cause the request to fail, even though I've used ua->ssl_opts( verify_hostname => 0 );?
  • What do I have to do to get a better error message out of LWP::UserAgent? Is this a bug in LWP::UserAgent?

This is on a Debian Jessie box with perl 5.20.2, and LWP::UserAgent 6.06.

In reply to How to get a better error message from LWP::UserAgent on missing SSL certificates? by moritz

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (1)
    As of 2021-01-26 00:12 GMT
    Find Nodes?
      Voting Booth?