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();