Java: sun.security.provider.certpath.SunCertPathBuilderException: Unable to Find Valid Certification Path to Requested Target
When attempting to download a file from an HTTPS server, you may encounter errors due to certificate issues. The error message "sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target" indicates a problem with the client-server authentication.
Ignoring Client-Server Authentication
If you wish to ignore the client-server authentication to bypass this error, here are the steps you can take:
Add the Certificate to JVM's Trust Store:
Using JAVA_HOME/jre: Navigate to JAVA_HOME/jre/lib/security/cacerts and use the keytool utility to import the certificate:
keytool -importcert -alias my-server-cert -trustcacerts -keystore cacerts -file YOUR_EXPORTED_CERTIFICATE
Using -Djavax.net.ssl.trustStore parameter: Run your application with the following parameter:
-Djavax.net.ssl.trustStore=YOUR_TRUST_STORE_PATH
By implementing these steps, you can ignore the client-server authentication and establish a secure connection to the HTTPS server.
The above is the detailed content of How to Resolve 'sun.security.provider.certpath.SunCertPathBuilderException: Unable to Find Valid Certification Path'?. For more information, please follow other related articles on the PHP Chinese website!