My java application was able to connect to the third party application using https SSL connection when the endpoint URL had IP address in it. Now, when the IP address got changed to Hostname, I am getting “SSL handshake exception” . Apart from this there were no code update or any other changes done. Only change what was done is that the thiry party is using Hostname in the Endpoint URL , instead of IP address.
Earlier URL: https://10.0.0.1:5368/invoke/Upload.Accept/receiveReply Present URL: https://service.serviceprovider.com:5368/invoke/Upload.Accept/receiveReply
Any ideas what is causing this and how to fix it?
Please let me know if any more details is required.
Below is the stacktrace of the error:
javax.net.ssl.SSLHandshakeException: Could not generate secret
at sun.security.ssl.DHCrypt.getAgreedSecret(DHCrypt.java:219)
at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1056)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:348)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
at com.etsalat.adapter.sadad.PaymentLoadAdapter.run(PaymentLoadAdapter.java:130)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.security.NoSuchAlgorithmException: TlsPremasterSecret SecretKeyFactory not available
at javax.crypto.SecretKeyFactory.<init>(SecretKeyFactory.java:122)
at javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:160)
at iaik.security.dh.DHKeyAgreement.engineGenerateSecret(Unknown Source)
at javax.crypto.KeyAgreement.generateSecret(KeyAgreement.java:648)
at sun.security.ssl.DHCrypt.getAgreedSecret(DHCrypt.java:217)
ServerHelloDonethe certificate was accepted.ServerHelloDonewas done, it should not be an certificate error. Is there anyway to validate the certificate for a particular URL?openssl s_client -connect service.serviceprovider.com:5368 -showcertsand check for "subject" section in the output.