I have code that uses a HttpsURLConnection to perform a 2-way SSL handshake. It creates and uses an SSL Socket factory as follows:
The problem I'm having is that in
Java 1.7 the code works fine, but in 1.6 it breaks with handshake error. After a lot of digging and stack traces I've isolated it to an "extra" handshake performed by Java 1.6. Specifically, Java 1.6 performs the following:
In Java 1.7, "SSLv2 client hello message" is never called. I've further isolated this to the
documentation for JSSE which is on point with "Cause: Some SSL/TLS servers will disconnect if a ClientHello message is received in a format it doesn't understand or with a protocol version number that it doesn't support.".
The problem I'm having is the only way I seem to be able to disable the extra code is by calling "System.setProperty("https.protocols", "TLSv1");". This is a server environment though, and setting that parameter could have side effects that would take a lot of time to
test. I haven't found another way, though. There is a SSLSocket.setEnabledProtocols() method, but the problem is HttpsURLConnection takes a factory, not a socket. I've tried extending my own SSL Socket factory with very little luck. Any suggestions?