When I execute the following code, why is the first handshake SSLv2, not TLSv1 or SSLv3?
How to use TLSV1 or SSLV3 for first handshake in Java?
String
For TLSv1: Starting the client jvm with
-Dhttps.protocols="TLSv1"
or using
System.setProperty("https.protocols", "TLSv1");
solved the problem for me.
Use SSLSocket
:
SSLSocket socket = factory.createSocket(host, 443);
String[] newProtocols = {"TLSv1"};
socket.setEnabledProtocols(newProtocols);
Which version of java are you using? Also how do you say it uses SSLv2? By default, java 1.6 will use TLSv1. There is a catch here, if you enable debug ssl, you might see SSLv2Hello format being used but if you close look the 'protocol vesion' inside the record layer will be TLSv1 (1.e version information wrapper under SSLv2 format). TCP level packet capture analysis using wireshark should confirm this. If you want to initiate in TLSv1 format only set https.protocols=TLSv1 (this might affect all the outgoing ssl calls) OR set on that specific socket like above. Do note that even if you five comma separated list (like https.protocols=SSLv3,TLSv1) it will start with TLSv1.