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

前端 未结 4 1189
臣服心动
臣服心动 2021-01-30 18:01

I\'m using Apache HttpComponents HttpClient(4.0.1) to make a HTTPS call, but I\'m this exception as the response:

 javax.net.ssl.SSLPeerUnverifiedException: peer         


        
相关标签:
4条回答
  • 2021-01-30 18:10

    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.

    0 讨论(0)
  • 2021-01-30 18:18

    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/

    0 讨论(0)
  • 2021-01-30 18:21

    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.

    0 讨论(0)
  • 2021-01-30 18:32

    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.

    0 讨论(0)
提交回复
热议问题