perlquestion
moritz
<p>I just spent several hours debugging some code using [mod://LWP::UserAgent]. The code could be reduced to this:
<code>
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;
}
</code>
<p>So pretty much a copy&paste from the LWP::UserAgent docs.</p>
<p>The error message I got was:</p>
<code>
Can't connect to myhost.local:443\n\n
500 Can't connect to myhost.local:443 at foo.pl line 15.
</code>
<p>After some debugging, strace finally showed me an ENOENT for an SSL CA file, which nudged me into the right direction.</p>
<p>So, my questions are:
<ul>
<li>Why does a missing CA file cause the request to fail, even though I've used <code>ua->ssl_opts( verify_hostname => 0 );</code>?</li>
<li>What do I have to do to get a better error message out of LWP::UserAgent? Is this a bug in LWP::UserAgent?</li>
</ul>
<p>This is on a Debian Jessie box with perl 5.20.2, and LWP::UserAgent 6.06.</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-616540">
[https://deploybook.com/|I'm writing a book on automating deployments and Continuous Delivery]. Feedback very welcome!
</div></div>