Sun Java System Web Server 6.1 SP7 Programmer's Guide to Web Applications

Fetching the Client Certificate

When you enable SSL and require client certificate authorization, your servlets have access to the client certificate as shown in the following example:

if (request.isSecure()) {[] certs;
         certs = request.getAttribute("javax.servlet.request.X509Certificate");
        if (certs != null) {
            clientCert = certs[0];
            if (clientCert != null) {
               // Get the Distinguised Name for the user.
      userDN = clientCert.getSubjectDN();


The userDn is the fully qualified Distinguished Name for the user.