Ignore certificate errors when requesting a URL in Java

后端 未结 5 1992
一个人的身影
一个人的身影 2020-12-19 23:35

I\'m trying to print a URL (without having a browser involved at all) but the URL is currently throwing the following:

javax.net.ssl.SSLHandshakeException: 
         


        
5条回答
  •  一生所求
    2020-12-20 00:26

    If it is the same server that you will be contacting each time, it might be okay to simply trust this one certificate by adding it to the trust store. I wouldn't add this to the default cacerts file, but you can make your own keystore and specify it through the javax.net.ssl.trustStore system property.

    Lastly, if you want to disable PKIX checking completely (which you should only do if you understand that this will compromise security quite a lot) the only way is to implement your own SSL context and trust manager as erickson has suggested.

提交回复
热议问题