United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6690018 RSAClientKeyExchange NullPointerException
JDK-6690018 : RSAClientKeyExchange NullPointerException

Details
Type:
Bug
Submit Date:
2008-04-17
Status:
Closed
Updated Date:
2011-03-07
Project Name:
JDK
Resolved Date:
2011-03-07
Component:
security-libs
OS:
windows_xp
Sub-Component:
javax.net.ssl
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows XP SP 2
(Occurs on ubuntu linux gutsy as well)

A DESCRIPTION OF THE PROBLEM :
A SSL connection is established to an https site and the SSL socket implementation fails to complete handshake.

The site has an self certified certificate present in the trusted keystore used.
When performed on JDK 1.5, the connection is established withouth a problem.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Standard HTTPSUrlConnection to a site with a custom certificate is trying to be established.
The sites certificate is present in the keystore used, and is successfully recognized.
Code sample is provided bellow. The test case works on Java 5.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code to establish an SSL conection.
ACTUAL -
The connection fails with the following stack trace:

Caused by: javax.net.ssl.SSLException: java.lang.NullPointerException
	at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(Unknown Source)
	at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown Source)
	at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
	at java.io.BufferedOutputStream.flush(Unknown Source)
	at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:94)
	... 35 more
Caused by: java.lang.NullPointerException
	at com.sun.net.ssl.internal.ssl.RSAClientKeyExchange.<init>(Unknown Source)
	at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverHelloDone(Unknown Source)
	at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
	at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
	at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(Unknown Source)
	... 39 more


ERROR MESSAGES/STACK TRACES THAT OCCUR :
Caused by: javax.net.ssl.SSLException: java.lang.NullPointerException
	at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(Unknown Source)
	at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown Source)
	at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
	at java.io.BufferedOutputStream.flush(Unknown Source)
	at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:94)
	... 35 more
Caused by: java.lang.NullPointerException
	at com.sun.net.ssl.internal.ssl.RSAClientKeyExchange.<init>(Unknown Source)
	at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverHelloDone(Unknown Source)
	at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
	at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
	at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(Unknown Source)
	... 39 more


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class SSLTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
		    System.setProperty("javax.net.ssl.trustStore", "config/jssecacerts.store");
		    System.setProperty("javax.net.ssl.trustStorePassword", "changeit");

		    
			URL url = new URL("https://qawf.firstcall.com/NASApp/Guardian/SOAPStreamRouterServlet0");
			URLConnection conn = url.openConnection();
			System.out.println( conn.getContent() );
			System.out.println( "Connection to "+url+" established." );
		} catch( Throwable t ) {
			System.out.println( "Connection failed." );
			t.printStackTrace();
		}
	}

}
---------- END SOURCE ----------

Release Regression From : 5.0
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

                                    

Comments
SUGGESTED FIX

For RSA_EXPORT key exchange method, check the server key exchange message against the server certificate key in length.
                                     
2008-05-30
EVALUATION

According to my replay of the bug, the customer's server uses RSA_EXPORT_... cipher suite, and the public key of the server certificate is 512 bits, and the server side does not send a server key exchange message. However, the current implementation needs a server key exchange message for RSA_EXPORT methods, which is not correct according to section 7.4.3, RFC2246.

"It is not legal to send the server key exchange message for the following key exchange methods:
    RSA
    RSA_EXPORT (when the public key in the server certificate is
    less than or equal to 512 bits in length)
..."
                                     
2008-05-30



Hardware and Software, Engineered to Work Together