• Post Reply Bookmark Topic Watch Topic
  • New Topic

Enable SSLv2Hello in java 7  RSS feed

 
Nate Astle
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to talk to a webservice in java 1.7. I noticed a bug on the side they are using in which they are trying to reply back with a SSLv2Hello message. This works in 1.6 but not 1.7. I am trying to figure out how to call a web service where the socket has the sslv2hello protocol enabled.

Here is what I have to enable the SSLv2Hello protocol, I am unsure if there is an easy way to use it without having to format xml packets manually.

SSLContext context = SSLContext.getInstance("TLSv1");
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sock = (SSLSocket) sslsocketfactory.createSocket("hostserver", 443);
String[] protocols = {"SSLv2Hello", "SSLv3"};
sock.setEnabledProtocols(protocols);

//open connection, send data, receive data, close connection....



 
Nate Astle
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have found the problem. Just for future purposes, this is disabled in the SunJ2EE implementation. You can try to work around by either setting a system property of
System.setProperty("https.protocols", "SSLv3,SSLv2Hello");
This would only work for the first request in JBoss AS 7 and then it would not work for subsequent requests throwing a unexpected_error during the handshake not sure about other version.
You can program to Java 6 but for any future upgrades you are stuck.
You can write your program in .NET and run on windows
you can manually setup connections with httpsurlconnection and sslsocketfactory creating your own sockets and setting the protocols manually.
You might be able to write your own SSLContextImpl and use that but I did not pursue that route.
but in the end I ended up using OpenJDK as the runtime instead of the Oracle version as this seems the simplest approach.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!