PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
时间: 2023-10-30 22:05:30 浏览: 189
SSL.7z,解决PKIX path building failed 的问题
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.
This error occurs when the SSL certificate of the target server cannot be validated by the Java Virtual Machine (JVM). The JVM is unable to establish a trusted connection because it cannot find a valid certification path.
To resolve this issue, you can try the following steps:
1. Update the Java Runtime Environment (JRE) or Java Development Kit (JDK) to the latest version available. This ensures that you have the latest trusted root certificates.
2. Import the SSL certificate of the target server into the Java keystore. You can use the keytool command-line tool to import the certificate. Here's an example command:
```
keytool -importcert -alias server -keystore cacerts -file server.crt
```
Replace "server" with an alias of your choice, "cacerts" with the path to the Java keystore file (usually located in the JRE installation directory), and "server.crt" with the path to the SSL certificate file.
3. If you are using a custom truststore, ensure that it contains all necessary certificates, including any intermediate or root certificates required to establish trust with the target server.
4. If you are running your application behind a proxy server, make sure that the proxy server's SSL certificate is valid and trusted by your JVM.
By following these steps, you should be able to resolve the PKIX path building failed error and establish a successful SSL connection.
阅读全文