2

I am trying to connect to a host using Java. The host when connected from the browser shows that it is using cipher suite TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA. When I run the code in Java to connect to the same host, the program is not sending the same cipher suite and so I get a handshake error.

Received fatal alert: handshake_failure

After reading over the internet I thought the cause could be due to different ciphers. So I tried to enable the same cipher in my Java program using:

String pickedCipher[] ={"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA"}; 
socket.setEnabledCipherSuites(pickedCipher);

This give me error:

Cannot support TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA with currently installed providers

I searched over internet and most found that I need to install Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files. Extrat the JAR's in .\jre\lib\security. I did the same but still I am not able to enable the needed cipher suite and keep getting the unsupported providers error.

I have searched and tried whatever is suggested over the internet but could not make the connection. Can anyone help me.

Code I am trying:

SSLSocketFactory factory = HttpsURLConnection.getDefaultSSLSocketFactory(); 
SSLSocket socket=null;
socket = (SSLSocket) factory.createSocket("147.249.141.13", 443);
enCiphersuite=socket.getEnabledCipherSuites();
socket.setEnabledCipherSuites(enCiphersuite);
socket.startHandshake();
jww
  • 97,681
  • 90
  • 411
  • 885
nav
  • 25
  • 8
  • 1
    You must have done it wrong. If you're using a JRE inside a JDK you Have to install it there as well. – user207421 Sep 28 '17 at 20:57
  • I have installed the JAR's in both the locations: C:\Program Files (x86)\Java\jdk1.6.0_45\jre\lib\security and C:\Program Files (x86)\Java\jre6\lib\security – nav Sep 29 '17 at 06:16
  • I removed all the Java version from the system and cleaned all the temp files. Installed Java and JCE. Worked like charm! Thanks! – nav Oct 03 '17 at 09:10

0 Answers0