Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6514454

A NullPointerException is throw when HTTPS connection is established

XMLWordPrintable

    • 1.6
    • 6
    • b16
    • x86
    • windows_xp
    • Verified

        FULL PRODUCT VERSION :
        java version "1.6.0"
        Java(TM) SE Runtime Environment (build 1.6.0-b105)
        Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [Version 5.1.2600]

        A DESCRIPTION OF THE PROBLEM :
        When an application started with JWS tries to establish a HTTPS connection, a NullPointerException is thrown. I have found out, that the bug only occurs, if you specify a custom HostnameVerifier.

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        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.startHandshake(Unknown Source)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
        at de.igel.rm.ServerConnection.connect(ServerConnection.java:1400)
        at de.igel.rm.ServerConnection.getServerVersion(ServerConnection.java:431)
        at de.igel.rm.gui.MainFrame$ConnectThread.work(MainFrame.java:914)
        at de.igel.util.WorkerThread.run(WorkerThread.java:32)
        Caused by: java.lang.NullPointerException
        at com.sun.deploy.security.X509ExtendedDeployTrustManager.isSupportedAlgorithm(Unknown Source)
        at com.sun.deploy.security.X509ExtendedDeployTrustManager.checkServerTrusted(Unknown Source)
        at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(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)
        ... 10 more

        ---------- BEGIN SOURCE ----------
        package de.igel;

        import javax.net.ssl.*;
        import java.net.URL;
        import java.io.InputStream;
        import java.io.IOException;
         
        public class HttpsTest
        {
            public static final String httpsUrl = "https://scgi.ebay.com/ws/eBayISAPI.dll?RegisterEnterInfo" ;
            public static void main( String[] args )
            {
                HttpsURLConnection.setDefaultHostnameVerifier( new NoHostnameVerify() );
                 try
                {
                    URL u = new URL( httpsUrl );
                    HttpsURLConnection con = (HttpsURLConnection)u.openConnection();
                    InputStream in = con.getInputStream();
                    int c = 0;
                    while( ( c = in.read() ) != -1 )
                    {
                        System.out.print( (char)c );
                    }
                }
                catch( IOException e )
                {
                    e.printStackTrace();
                }
             }
        }
         
        class NoHostnameVerify implements HostnameVerifier
        {
            public boolean verify(String parm1, SSLSession parm2)
            {
                return true;
            }
        }
         
        I have used the following JNLP descriptor:
         
        <jnlp spec="1.0+" codebase="http://localhost:8080/" href="http://localhost:8080/test/httpstest.jnlp">
          <information>
            <title>HTTPS test</title>
            <vendor>IGEL Technology GmbH</vendor>
            <homepage href="http://www.igel.de"/>
            <description>Trys to open a HTTPS connection</description>
            <offline-allowed/>
          </information>
          <security>
            <all-permissions/>
          </security>
          <resources>
            <j2se href="http://java.sun.com/products/autodl/j2se" version="1.5+"/>
            <jar href="http://localhost:8080/test/test.jar" download="eager"/>
          </resources>
          <application-desc main-class="de.igel.HttpsTest"/>
        </jnlp>
        ---------- END SOURCE ----------

        REPRODUCIBILITY :
        This bug can be reproduced always.

              dgu Dennis Gu (Inactive)
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: