The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::LDAPS - use LDAP over an SSL connection

SYNOPSIS

 use Net::LDAPS;

 $ldaps = new Net::LDAPS('myhost.example.com',
                         port => '10000',
                         verify => 'require',
                         capath => '/usr/local/cacerts/');

DESCRIPTION

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.

CONSTRUCTOR

new ( HOST [, OPTIONS ] )

Create a new connection. HOST is the hostname to contact. OPTIONS is a number of key/value pairs - additional keys to those understood by Net::LDAP::new are:

verify

How to verify the server's certificate, either 'none' (the server may provide a cert but don't verify it - this may mean you are be connected to the wrong server), 'optional' (verify if the server offers a cert), or 'require' (the server must provide a cert, and it must be valid.) If you set verify to optional or require, you must also set either cafile or capath.

ciphers

Specify which subset of cipher suites are permissible for this connection, using the standard OpenSSL string format. The default value for ciphers is 'ALL', which permits all ciphers.

clientcert
clientkey

If you want to use the client to offer a certificate to the server for SSL authentication (which is not the same as for the LDAP Bind operation) then set clientcert to the user's certificate file, and clientkey to the user's private key file.

capath
cafile

When verifying the server's certificate, either set capath to the pathname of the directory containing CA certificates, or set cafile to the filename containing the certificate of the CA who signed the server's certificate.

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 -noout < cacert.pem`.0

(assuming that the certificate of the CA is in cacert.pem.)

ADDITIONAL METHODS

cipher

Returns the cipher mode being used by the connection, in the string format used by OpenSSL.

certificate

Returns an X509_Certificate object containing the server's certificate. See the IO::Socket::SSL documentation for information about this class.

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";

SEE ALSO

Net::LDAP, IO::Socket::SSL

BUGS

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;
    }

AUTHOR

Chris Ridd <chris.ridd@messagingdirect.com>

COPYRIGHT

Copyright (c) 2000-2001, 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.