Ignore certificate errors when requesting a URL in Java

后端 未结 5 1991
一个人的身影
一个人的身影 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:29

    This is possibly because your certificate in your keystore for accessing target HTTPS URL does not match the certificate from server.

    You need to import the certificate in to your JVM's keystore. Obtain keystore certificatesto access this URL and then importit into the main keystore with

    keytool -importkeystore -srckeystore /path/to/custom/keystore -destkeystore $JAVA_HOME/jre/lib/security/cacerts

    Assuming you are using Java from $JAVA_HOME

提交回复
热议问题