-
Bug
-
Resolution: Fixed
-
P5
-
1.0.2
-
1.0.3
-
x86
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2110121 | 1.4.0 | Bradford Wetmore | P5 | Resolved | Fixed | beta2 |
I get a java.lang.NullPointerException if I call the getCipherSuite() method
of HttpsURLConnection before calling the connect() method.
It works fine if I call it after the connect() method.
Here is the code I used with a custom HTTPS server and a KeyStore that I
generated with keytool.
Running it with: java Bug 1, causes a java.lang.NullPointerException
Running it with: java Bug 2, works fine.
import java.io.*;
import java.net.*;
import java.security.*;
import com.sun.net.ssl.HttpsURLConnection;
public class Bug {
public static void main(String[] args) throws Exception {
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("javax.net.ssl.trustStore", "keystore");
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
URL url = new URL("https", "localhost", 2001, "file");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
if (args.length == 1 && args[0].equals("1")) {
System.out.println("Cipher Suite = " + connection.getCipherSuite());
}
connection.connect();
if (args.length == 1 && args[0].equals("2")) {
System.out.println("Cipher Suite = " + connection.getCipherSuite());
}
}
}
of HttpsURLConnection before calling the connect() method.
It works fine if I call it after the connect() method.
Here is the code I used with a custom HTTPS server and a KeyStore that I
generated with keytool.
Running it with: java Bug 1, causes a java.lang.NullPointerException
Running it with: java Bug 2, works fine.
import java.io.*;
import java.net.*;
import java.security.*;
import com.sun.net.ssl.HttpsURLConnection;
public class Bug {
public static void main(String[] args) throws Exception {
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("javax.net.ssl.trustStore", "keystore");
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
URL url = new URL("https", "localhost", 2001, "file");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
if (args.length == 1 && args[0].equals("1")) {
System.out.println("Cipher Suite = " + connection.getCipherSuite());
}
connection.connect();
if (args.length == 1 && args[0].equals("2")) {
System.out.println("Cipher Suite = " + connection.getCipherSuite());
}
}
}
- backported by
-
JDK-2110121 HttpsURLConnection.getCipherSuite throws NullPointerException
-
- Resolved
-