Net::LDAPS - use LDAP over an SSL connection
use Net::LDAPS;
$ldaps = new Net::LDAPS('myhost.example.com', port => '10000', verify => 'require', capath => '/usr/local/cacerts/');
Communicate using the LDAP protocol to a directory server using a potentially encrypted (SSL) network connection.
This class is a subclass of Net::LDAP so all the normal Net::LDAP methods can be used with a Net::LDAPS object; see the documentation for Net::LDAP to find out how to query a directory server using the LDAP protocol.
The directory in 'capath' must contain certificates named using the hash value of themselves. To generate these names, use OpenSSL thusly:
ln -s cacert.pem `openssl x509 -hash -nout < cacert.pem`.0
(assuming that the certificate of the CA is in cacert.pem.)
For example, to get the subject name (in a peculiar OpenSSL-specific format, different from RFC 1779 and RFC 2253) from the server's certificate, do this:
print "Subject DN: " . $ldaps->certificate->subject_name . "\n";
Several apparently bogus warnings are emitted when initializing the two underlying modules used by Net::LDAPS, namely IO::Socket::SSL and Net::SSLeay. To avoid these, don't initialize via 'use Net::LDAPS' and instead try initializing Net::LDAPS like this:
BEGIN { # Turn off all warnings etc whilst initializing # IO::Socket::SSL and Net::SSLeay. local $^W = 0; no strict; require Net::SSLeay; # The /dev/urandom is a device on Linux that returns # random data. Net::SSLeay::randomize('/dev/urandom'); require Net::LDAPS; }
Chris Ridd <chris.ridd@messagingdirect.com>
Copyright (c) 2000, Chris Ridd and Graham Barr. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.