

Warning! This socket factory will accept all certificates, **** at your own risk. If your application runs on Java 1.

For example, by setting Dhttps.protocolsTLSv1.2. Then you will create an extension of SSLSocketFactory. If your application runs on Java 1.7 or Java 1.6 (update 111 or later), you can set the https.protocols system property when starting the JVM to enable additional protocols for connections made using the HttpsURLConnection class. This method requires using the built-in HttpsURLConnection, which is very primitive if you're used to using things like Unirest, or even apache HttpClient.įirst you need to add Bounc圜astle to you pom. As a disclaimer, I know very little about https security, and I'm sure there are some issues that a more knowledgeable person may notice. 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.I have come up with a solution that does not require upgrading to Java 8.

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

Main, WRITE: TLSv1 Handshake, length = 163 main, received EOFException: error main, handling exception: : Remote host closed connection during handshake main, SEND TLSv1 ALERT: fatal, description = handshake_failure main, WRITE: TLSv1 Alert, length = 2Īs you can see TLSv1 even after putting the said variable Java 1.7 is using TLSv1 2Hello=false 3=false 1=false 1.1=true 1.2=true -Dhttps.protocols=TLSv1.1,TLSv1.2īut still same error is happing and I can see in SSL debug file the following : I tried to over ride the default behavior by adding the setting the following variables on JVM level: : Remote host closed connection during handshakeĪfter 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. When I am trying to run the client application I am getting the error I am building a web-service application with Java 1.7 that communicate with external party server.
