且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

解决 javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed 错误?

更新时间:2021-10-24 05:50:11

您需要将App2的证书添加到位于JVM的信任库文件中代码>$JAVA_HOME\lib\security\cacerts.

You need to add the certificate for App2 to the truststore file of the used JVM located at $JAVA_HOME\lib\security\cacerts.

首先,您可以通过运行以下命令来检查您的证书是否已经在信任库中:keytool -list -keystore "$JAVA_HOME/jre/lib/security/cacerts"(不需要提供密码)

First you can check if your certificate is already in the truststore by running the following command: keytool -list -keystore "$JAVA_HOME/jre/lib/security/cacerts" (you don't need to provide a password)

如果您的证书丢失,您可以使用浏览器下载它并使用以下命令将其添加到信任库中:

If your certificate is missing, you can get it by downloading it with your browser and add it to the truststore with the following command:

keytool -import -noprompt -trustcacerts -alias <AliasName> -file   <certificate> -keystore <KeystoreFile> -storepass <Password>

示例:

keytool -import -noprompt -trustcacerts -alias myFancyAlias -file /path/to/my/cert/myCert.cer -keystore /path/to/my/jdk/jre/lib/security/cacerts/keystore.jks -storepass changeit

导入后,您可以再次运行第一个命令来检查您的证书是否已添加.

After import you can run the first command again to check if your certificate was added.

可以在此处找到 Sun/Oracle 信息.

Sun/Oracle information can be found here.