SSL connection with a specific version of the protocol

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?

+4
source share
2 answers

Oracle Java does not support SSLv2. It only supports SSLv2Hello, combined with higher protocol layers, for some ancient websites that require it. Hence the error message you received. SSLv2Hello is a pseudo-protocol that simply tells Java to start with an SSLv2Hello message instead of SSLv3 or TLS Hello messages.

, IBM JRE SSLv2.

, , SSLv3, TLS .. ( , ). , Oracle JRE.

+4

http://tools.ietf.org/html/rfc6176

, SSL V2 , SSL V2 , V2.

+1

Source: https://habr.com/ru/post/1523329/


All Articles