I read Oracle's doc here and have tried to enable TLSv1.2 on Java 7(1.7.0_80-b15) for a few day with no luck.
I wanna enable TLSv1.2 on it, so I can call a web service with https protocol. I use this code which I thought had enabled that already.
SSLContext ctx = SSLContext.getInstance("TLSv1.2");
ctx.init(null, null, new SecureRandom());
SSLContext.setDefault(ctx);
URL url = new URL ("https://testotp.ktc.co.th");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setSSLSocketFactory(ctx.getSocketFactory());
And I even put jdk.tls.disabledAlgorithms=SSLv2Hello, SSLv3, TLSv1, TLSv1.1
on java.security.
Still, I got this error when the web service method was called.
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.net.SocketException: Connection reset
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.net.SocketException: Connection reset
...
So I set these debugger attributes on JVM and this is what I got.
For -Djavax.net.debug=ssl:defaultctx
I got.
trigger seeding of SecureRandom
done seeding SecureRandom
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
Ignoring unavailable cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256
Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA
Allow unsafe renegotiation: false
Allow legacy hello messages: true
Is initial handshake: true
Is secure renegotiation: false
%% No cached client session
*** ClientHello, TLSv1.2
...
...
main, WRITE: TLSv1.2 Handshake, length = 219
main, handling exception: java.net.SocketException: Connection reset
main, SEND TLSv1 ALERT: fatal, description = unexpected_message
main, WRITE: TLSv1 Alert, length = 2
main, Exception sending alert: java.net.SocketException: Connection reset by peer: socket write error
main, called closeSocket()
For -Djavax.net.debug=ssl:sslctx
I got
trigger seeding of SecureRandom
done seeding SecureRandom
trigger seeding of SecureRandom
done seeding SecureRandom
main, handling exception: java.net.SocketException: Connection reset
main, SEND TLSv1 ALERT: fatal, description = unexpected_message
main, Exception sending alert: java.net.SocketException: Connection reset by peer: socket write error
main, called closeSocket()
From the first debugger, I assumed I had already enabled TLSv1.2 for it so I got "ClientHello, TLSv1.2", but handshake still failed and the socket got closed. It might have something to do with the face that TLS version in defaultctx is differnet from sslctx, but I don't quite understand what they are.
I also check that the web service has https protocol by running telnet https://thathost.com 443
and it does exist.
This post seems like my case, but there's no answer for it too. What can I try next?