Subject: | LDAPS SSL validation |
Date: | Thu, 28 Jul 2011 16:30:13 -0700 |
To: | bug-perl-ldap [...] rt.cpan.org |
From: | Kevan Carstensen <kacarstensen [...] csupomona.edu> |
Hi,
I noticed that Net::LDAP doesn't seem to correctly verify the SSL
certificate presented by a remote LDAP server, even if verify =>
'require' is given when creating a connection, as in:
my $ldap = new Net::LDAP(
"ldaps://some.ldap.server",
version => 3,
verify => "require",
capath => "/etc/ssl/certs",
);
Specifically, Net::LDAP doesn't seem to attempt to verify the server's
identity at all -- as long as the server presents a certificate signed
by a CA that the client trusts, the client allows the connection to
proceed. This is intuitively wrong, violates section 3.1.3 of RFC 4513,
which describes how LDAP clients should validate SSL certificates, and
effectively allows anyone with an SSL certificate for any site signed by
a widely-trusted CA to successfully impersonate, from the perspective of
Net::LDAP clients, any LDAP server, even if those clients are configured
to strictly validate server certificates.
This behavior seems to be a result of IO::Socket::SSL's default behavior
regarding identity verification, which is to not validate identities:
SSL_verifycn_scheme
Set the scheme used to automatically verify the hostname of the
peer. See the information about the verification schemes in
verify_hostname. The default is undef, e.g. to not automatically
verify the hostname.
(from http://search.cpan.org/~sullr/IO-Socket-SSL-1.44/SSL.pm)
We can easily address this by changing the options passed to
IO::Socket::SSL's new and start_SSL functions. I'm attaching a patch
that does this, setting SSL_verifycn_name to 'ldap'. This behaves
correctly in my tests: LDAPS connections to a server only succeed if the
server presents a certificate (signed by a CA trusted by the client)
that correctly identifies the name that the client connected to.
Details about my setup:
OS/platform: Linux hostname 2.6.37-gentoo-r4 #3 SMP Mon Jul 25 13:44:53 PDT 2011 x86_64 Intel(R) Xeon(TM) CPU 3.16GHz GenuineIntel GNU/Linux
Perl version: This is perl 5, version 12, subversion 3 (v5.12.3) built for x86_64-linux (with 13 registered patches, see perl -V for more detail)
Locally applied patches:
0001-gentoo_MakeMaker-RUNPATH.diff
0002-gentoo_config_over.diff
0003-gentoo_cpan_definstalldirs.diff
0004-gentoo_cpanplus_definstalldirs.diff
0005-gentoo_create-libperl-soname.diff
0006-gentoo_MakeMaker-delete_packlist.diff
0007-fixes_8d66b3f9_h2hp_fix.diff
0008-fixes_f178b03b_h2ph_using_deprecated_goto.diff
0009-gentoo_mod-paths.diff
0010-gentoo_enc2xs.diff
0011-gentoo_IO-Compress_AutoLoader_dropped_from_Compress-Zlib.diff
0012-gentoo_drop-fstack-protector.diff
0013-fixes_539689e74a_unwarrantedly_laundering_tainted_data.diff
Package and version: perl-ldap-0.4001
Thanks,
--
Kevan Carstensen <kacarstensen@csupomona.edu>
Operating Systems Analyst, I&IT Systems, Cal Poly Pomona
Message body is not shown because sender requested not to inline it.