perlwww-mechanizelwp

Scripts broke after upgrading LWP "certificate verify failed"


I have a lot of scripts, most of them based around WWW::Mechanize that scrape data off of misc hardware that is accessible via HTTPs. After upgrading most of my perl installation and its modules, all scripts using HTTPS:// broke because of "certificate verify failed"

This is a result of the fact that the newer versions of LWP does a proper check on the certificate and dies if something doesn't match.

In my case, the failed certificate authentication is expected due to the circumstances, so i needed to find a way of cleanly circumventing this check.


Solution

  • I prepended my code with:

    $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;
    

    This caused the script to circumvent the check in a clean and simple way.