I am trying to make an SSL connection with a specific protocol version with the following JAVA code:
System.out.println("Locating socket factory for SSL...");
SSLSocketFactory sslsocketfactory = (SSLSocketFactory)SSLSocketFactory.getDefault();
System.out.println("Creating secure socket to " + https_url + ":443");
SSLSocket sslSocket = (SSLSocket)sslsocketfactory.createSocket();
String []protocol = {"SSLv2Hello"};
sslSocket.setEnabledProtocols(protocol);
SocketAddress addr = new InetSocketAddress(https_url,443);
sslSocket.connect(addr);
String [] P = sslSocket.getEnabledProtocols();
System.out.println("Enabled Protocol: " + Arrays.toString(P));
When I run the code, I get the following exception:
Exception in thread "main" java.lang.IllegalArgumentException: SSLv2Hello cannot be enabled unless at least one other supported version is also enabled.
at sun.security.ssl.ProtocolList.(Unknown Source)
at sun.security.ssl.ProtocolList.(Unknown Source)
at sun.security.ssl.SSLSocketImpl.setEnabledProtocols(Unknown Source)
at CheckByURL.test(CheckByURL.java:36)
at CheckByURL.main(CheckByURL.java:15)
When I tried with a different version of SSL, it worked well.
Does anyone know how to solve this problem?
source
share