Post

java7 TLS 1.2

java7 TLS 1.2

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  
  • Via SSLContext
1
2
3
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, null, null);
SSLContext.setDefault(sslContext);
This post is licensed under CC BY 4.0 by the author.