Java 7 defaults to TLS 1.0, which many servers started rejecting around 2017-2018. If you’re running an older Java app and suddenly getting SSL handshake failures against a server you didn’t change, this is almost certainly the problem. The SSLContext approach is the cleanest fix when you control the connection code.
- Enable tls1.2 support via system parameter
1
| $ java -Djdk.tls.client.protocols=TLSv1.2
|
- Enable tls1.2 support via JAVA_OPTS
1
| $ java -Djdk.tls.client.protocols=TLSv1.2
|
1
| $ JAVA_OPTS=$JAVA_OPTS -Djdk.tls.client.protocols=TLSv1.2
|
1
2
3
| SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, null, null);
SSLContext.setDefault(sslContext);
|