Complete Contents
Preface
Chapter 1 Understanding LDAP
Chapter 2 Using the Netscape Directory SDK for Java
Chapter 3 Quick Start
Chapter 4 Writing an LDAP Client
Chapter 5 Using the LDAP Java Classes
Chapter 6 Searching the Directory
Chapter 7 Using Filter Configuration Files
Chapter 8 Adding, Updating, and Deleting Entries
Chapter 9 Comparing Values in Entries
Chapter 10 Working with LDAP URLs
Chapter 11 Getting Server Information
Chapter 12 Connecting Over SSL
Chapter 13 Working with LDAP Controls
Chapter 14 Using SASL Authentication
Chapter 15 Using Netscape's JNDI Service Provider
Chapter 16 Working with Extended Operations
Chapter 17 Using the Asynchronous Interface
Glossary
Directory SDK for Java 4.0 Programmer's Guide: Connecting Over SSL
Previous Next Contents Index


Chapter 12 Connecting Over SSL

This chapter describes the process of enabling an LDAP client to connect to an LDAP server over the Secure Sockets Layer (SSL) protocol. The chapter covers the procedures for connecting to an LDAP server and authenticating.

The chapter includes the following sections:


How SSL Works with the Netscape Directory SDK for Java
The Netscape Directory SDK for Java includes classes and methods to enable your application to connect to an LDAP server over a Secure Sockets Layer (SSL).

Understanding SSL
The primary goal of the SSL Protocol is to provide privacy and reliability between two communicating applications. For more information on SSL, see:

The Netscape Directory SDK for Java supports SSL 3.0. Note that SSL is not supported by all LDAP servers.

SSL Over LDAP
When an LDAP client connects to an LDAP server over SSL, the LDAP server identifies itself by sending its certificate to the LDAP client. The LDAP client needs to determine whether or not the certificate authority (CA) who issued the certificate is trusted.

The LDAP server may also request that the client send a certificate to authenticate itself. (This process is called certificate-based client authentication.)

After receiving the client's certificate, the LDAP server determines whether or not the CA who issued the certificate is trusted. If the CA is trusted, the server uses the subject name in the certificate to determine if the client has access rights to perform the requested operation.

In order to use SSL, you need a certificate database to hold the CA certificate and (if certificate-based client authentication is used) the client's certificate. For details, see "Prerequisites for Connecting Over SSL".

Interfaces and Classes for SSL
The Netscape Directory SDK for Java includes the LDAPSocketFactory interface, which describes a single method, makeSocket, that returns a socket to a given server (specified by a host name and port number). To establish an SSL connection, you need to create an object of a class that implements this interface.

Note that the classes that implement this interface in the Netscape Directory SDK for Java rely on a separate class that implements SSL sockets. In the constructors for object that implement LDAPSocketFactory, you typically need to specify the name of a class that implements SSL sockets.

The following classes implement this interface:

You can construct an object of one of these factory classes and pass the factory object to the constructor for the LDAPConnection object to identify the socket factory that you want used for the connection.


Prerequisites for Connecting Over SSL
The LDAP Java classes that enable you to connect over SSL rely assume the following:

Essentially, when your client sends an initial request to the secure LDAP server, the server sends its certificate back to your client. Your client determines which CA issued the server's certificate and searches the certificate database for the certificate of that CA.

If your client cannot find the CA certificate or if the CA certificate is marked as "not trusted," your client refuses to connect to the server.

If you are using certificate-based client authentication, your client retrieves its certificate from the certificate database and sends it to the server for authentication. The server determines which CA issued the client's certificate and searches its certificate database for the certificate of that CA.

If the server cannot find the CA certificate or if the CA certificate is marked as "not trusted," the server refuses to authenticate your client.


Connecting to the Server Over SSL
To connect to an LDAP server using SSL, do the following:

  1. Construct a new LDAPSSLSocketFactory object or a new LDAPSSLSocketWrapFactory object.

  1. Pass the object you constructed to the LDAPConnection constructor.

Using Certificate-Based Client Authentication
Some LDAP servers may be configured to use certificate-based client authentication. A server may request that your client send a certificate to identify itself.

Using the Netscape Directory SDK for Java, you can set up your client to perform certificate-based authentication in either of the following situations:

Note the following:

To enable an applet to use certificate-based client authentication, do the following:

  1. Construct a new LDAPSSLSocketFactory object.
  2. Invoke the enableClientAuth method of the object to enable certificate-based client authentication.
  3. Pass the object you constructed to the LDAPConnection constructor.

 

© Copyright 1999 Netscape Communications Corporation. All rights reserved.