Why am I getting an exception javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated?

走远了吗. 提交于 2019-12-02 15:52:09
Binu George

The exception message

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated

doesn't always indicate the root cause of the issue. You may need to enable the SSL handshake debug by adding theJava VM parameter -Djavax.net.debug=ssl:handshake. Once you've added that you will get more helpful error messages. If the remote server uses a certificate that is not trusted you will see the following error message:

javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

If that is the case then the answer by @Abhishek will solve the issue.

as mentioned above either you import the certificate

  1. Start command prompt in directory which you have placed certificate (e.g. XYZ.cer)
  2. Run following command just change the active jre path (and please notice ~ symbol )
  3. keytool -import -alias XYZ -file XYZ.cer -keystore C:/Program~1/Java/jdk1.6.0_23/jre/lib/security/cacerts -storepass changeit

                               OR
    

use your own trust manager http://tech.chitgoks.com/2011/04/24/how-to-avoid-javax-net-ssl-sslpeerunverifiedexception-peer-not-authenticated-problem-using-apache-httpclient/

Any SSL connection issue can result in this error.

One of my solution is upgrade java from 6 to 8. Our problem is the server we meant to communicate is stop supporting TLS 1.0. And java 6 does not support upper version of TLS 1.0. After update Java (even without upgrade dropwizard) it works.

Make sure that the server URL is supposed to use https instead of http. You can get this error trying to set up a secure connection to an http URL.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!