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

前端 未结 4 1188
臣服心动
臣服心动 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.

提交回复
热议问题