• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Disabling handshake hello message in Java 1.6

 
author
Posts: 4356
45
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Scott Selikoff wrote: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?



I think using a custom implementation of SSLSocketFactory should work, but the trick will be to use it only for overriding the enabled protocols and letting the usual SSLSocketFactory do the rest of the job. So something like:



The custom SSLSocketFactory implementation will then look like:



I haven't given it a try but I think it should work.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Scott Selikoff wrote:
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.



For those curious as to why this works fine in Java 1.7, here's the reason from the Java 7 security enhancements/changes http://docs.oracle.com/javase/7/docs/technotes/guides/security/enhancements-7.html:

Changes in Java 7 wrote:
SSLv2Hello disabled by default on the client: In Java SE 7, SSLv2Hello is removed from the default enabled protocol list on the client.

 
Scott Selikoff
author
Posts: 4356
45
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Beautiful wrapper implementation Jaikiran! Works perfectly. Thank you so much!
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scoot and Jaikiran. I am also facing the similar issue. Can you please tell me whether we have an option to start the tomcat using TLSv1 in client communication rather than changing the entire code or upgrade the new JDK version.[1.7]

Thanks,
Abdul Wahid
 
reply
    Bookmark Topic Watch Topic
  • New Topic