libwww perl in ubuntu always enforces HTTPS server certificate
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libwww-perl (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Given this simple code:
$ua = LWP::UserAgent-
$ua-
$ua-
$ua->ssl_opts( verify_hostname => 0 );
push @{ $ua->requests_
my $req = HTTP::Request->new( GET =>
$req-
$req-
my $res = $ua->request($req);
LOGDIE "Error getting PE routers via REST to $server: ".$res-
"
if ! $res->is_success;
I get this message:
Error getting PE routers via REST to blc.serv.
LWP::Protocol:
Strace shows that the code is looking for a CA file from the OpenSSL package. blc.serv.
BUT it should not be trying to verify this at all due to the verify_hostname setting.
In HTTP::Protocol:
sub _extra_sock_opts
{
my $self = shift;
my %ssl_opts = %{$self-
if (delete $ssl_opts{
$ssl_opts{
$ssl_opts{
}
else {
$ssl_opts{
}
if ($ssl_opts{
unless (exists $ssl_opts{
eval {
require Mozilla::CA;
};
if ($@) {
if ($@ =! /^Can't locate Mozilla\/CA\.pm/) {
$@ = <<'EOT';
Can't verify SSL peers without knowing which Certificate Authorities to trust
This problem can be fixed by either setting the PERL_LWP_
envirionment variable or by installing the Mozilla::CA module.
To disable verification of SSL peers set the PERL_LWP_
envirionment variable to 0. If you do this you can't be sure that you
communicate with the expected peer.
EOT
}
die $@;
}
$ssl_
}
}
$self-
return (%ssl_opts, $self->
}
Then I get this instead
Error getting PE routers via REST to blc.serv.
which means that the SSL handshake was completed.
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: libwww-perl 6.05-2
ProcVersionSign
Uname: Linux 3.13.0-43-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.6
Architecture: amd64
Date: Wed Jan 7 16:05:09 2015
InstallationDate: Installed on 2014-12-19 (19 days ago)
InstallationMedia: Ubuntu-Server 14.04 LTS "Trusty Tahr" - Release amd64 (20140416.2)
PackageArchitec
SourcePackage: libwww-perl
UpgradeStatus: No upgrade log present (probably fresh install)
The option verify_hostname is like the name suggests only responsible for verifying the host name against the certificate. It does not control the verification of the certificate chain or any other certificate validations, even if it can be used like this in some versions of LWP::Protocol: :https. But this is actually a bug, see https:/ /github. com/libwww- perl/lwp- protocol- https/pull/ 14 (very long discussion).
The only documentation of the option verify_hostname in LWP::UserAgent says:
When TRUE LWP will for secure protocol schemes ensure it connects to servers that have a valid certificate
Which confirms that this option cares about verifying the host name only.
To disable any kind of certificate validation you have to use ssl_opts to set SSL_verify_mode to 0 (i.e. SSL_VERIFY_NONE).