Using Two-Way SSL Authentication with Servlets

5-16 Programming Security for Oracle WebLogic Server

5.4.3.4 Using Two-Way SSL Authentication with Servlets

To authenticate Java clients in a servlet or any other server-side Java class, you must check whether the client presented a digital certificate and if so, whether the certificate was issued by a trusted certificate authority. The servlet developer is responsible for asking whether the Java client has a valid digital certificate. When developing servlets with the WebLogic Servlet API, you must access information about the SSL connection through the getAttribute method of the HTTPServletRequest object. The following attributes are supported in WebLogic Server servlets: ■ javax.servlet.request.X509Certificate ■ java.security.cert.X509Certificate []—returns an array of the X.509 certificate. ■ javax.servlet.request.cipher_suite—returns a string representing the cipher suite used by HTTPS. ■ javax.servlet.request.key_size— returns an integer 0, 40, 56, 128, 168 representing the bit size of the symmetric bulk encryption key algorithm. ■ weblogic.servlet.request.SSLSession ■ javax.net.ssl.SSLSession—returns the SSL session object that contains the cipher suite and the dates on which the object was created and last used. You have access to the user information defined in the digital certificates. When you get the javax.servlet.request.X509Certificate attribute, it is an array of type java.security.cert.X509Certificate. You simply cast the array to that type and examine the certificates. A digital certificate includes information, such as the following: ■ The name of the subject holder, owner and other identification information required to verify the unique identity of the subject. ■ The subjects public key ■ The name of the certificate authority that issued the digital certificate ■ A serial number ■ The validity period or lifetime of the digital certificate as defined by a start date and an end date

5.4.4 Using a Custom Hostname Verifier

A hostname verifier validates that the host to which an SSL connection is made is the intended or authorized party. A hostname verifier is useful when a WebLogic client or a WebLogic Server instance is acting as an SSL client to another application server. It helps prevent man-in-the-middle attacks. Note: For information on JNDI contexts and threads and how to avoid potential JNDI context problems, see JNDI Contexts and Threads and How to Avoid Potential JNDI Context Problems in Programming JNDI for Oracle WebLogic Server.