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
@ikegami makes a good argument for why you don't want to disable SSL hostname verification, but doesn't directly mention how to avoid it.
If you're talking to a public system with a CA-signed certificate, you need to point LWP to your distribution's root certificate collection. Under a Debian-based system (Ubuntu, etc.), this is kept under /etc/ssl/certs/
.
BEGIN {
$ENV{HTTPS_CA_DIR} = '/etc/ssl/certs'
}
If you are talking to your own server with a self-signed certificate, you can save a copy of that certificate on the client, and point your script to that particular file.
BEGIN {
$ENV{HTTPS_CA_FILE} = '/path/to/my/server-certificate.crt'
}
You could instead set these in the environment before running your script (e.g. export them from your shell), or you could apply the settings directly to your UserAgent object. See the LWP::UserAgent documentation for more details; search for ssl_opts
(around halfway down the page).