Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to enable TLSv1.2 in Java 1.7

Salman5Aug 25 2016 — edited Aug 30 2016

I am building a web-service application with Java 1.7 that communicate with external party server. When I am trying to run the client application I am getting the error

javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake

After long search and check with the third party server admin, I found out that I need to use TLSv1.2 not TLSv1 which is the default one used by Java 1.7. I tried to over ride the default behavior by adding the setting the following variables on JVM level:

-Ddeployment.security.SSLv2Hello=false -Ddeployment.security.SSLv3=false -Ddeployment.security.TLSv1=false -Ddeployment.security.TLSv1.1=true -Ddeployment.security.TLSv1.2=true -Dhttps.protocols=TLSv1.1,TLSv1.2

But still same error is happing and I can see in SSL debug file the following :

*** ClientHello, TLSv1

.....

***

main, WRITE: TLSv1 Handshake, length = 163 main, received EOFException: error main, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake main, SEND TLSv1 ALERT:  fatal, description = handshake_failure main, WRITE: TLSv1 Alert, length = 2

main, called closeSocket()

As you can see TLSv1 even after putting the said variable Java 1.7 is using TLSv1

Question

How to force Java 1.7 client to use TlSv 1.2 while connection to third party server ?

Extra

Just for testing purpose and to make sure that there is no other problem causing the issue,  I tried to run the exact same client application with Java 1.8 and everything works perfectly fine because Java 1.8 uses TLSv1.2 by default

This post has been answered by Puthanampatti on Aug 28 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 27 2016
Added on Aug 25 2016
11 comments
23,340 views