SSLPeerUnverifiedException: peer not authenticated

前端 未结 2 1072
执笔经年
执笔经年 2020-12-02 23:48

Yet again, the dreary Problem of SSLPeerUnverified, but I\'m not using self signed certificates. I try to connect to a host using https. This host has a correct certificate,

相关标签:
2条回答
  • 2020-12-02 23:59

    It seems that you need to import the certificate into the trusted keystore your JVM is using. If you are not using a different trusted keystore in your application this will be "cacerts".

    You can follow a step by step guide at "How to Fix 'SSLPeerUnverifiedException: peer not authenticated' Exception in Groovy / Java ".

    Short version:

    1. Run the following command, replace $ADDRESS with the URL, minus the "https://":

      echo -n | openssl s_client -connect $ADDRESS:443 | \
        sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/$ADDRESS.cert
      
    2. Run the following command, replace $ALIAS a short name for the key, $ADDRESS with the cert name from above, $PATH with the path to cacerts in your JRE.

       sudo keytool -importcert -alias "$ALIAS" -file /tmp/$ADDRESS.cert \
         -keystore $PATH/cacerts -storepass changeit
      
    0 讨论(0)
  • 2020-12-03 00:15

    Previous answer link doesn't work, so I attach additional:

    https://blogs.oracle.com/java-platform-group/entry/self_signed_certificates_for_a

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