I am getting the error "sun.security.validator.ValidatorException.." what should I do?

The error below means Java is trying to access a URL but doesn't have the correct or up to date certificate.

sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target

To fix this issue:

  1. Obtain the certificate from the application owners. It could be your IT department or app developers. 
  2. Add the certificate for the target application to the truststore file of the JVM located at %JAVA_HOME%\lib\security\cacerts
  3. You can always check if the certificate is already in the trust store by running the following command: keytool -list -keystore "%JAVA_HOME%/jre/lib/security/cacerts
  4. If the certificate is not showing, download it from your browser and add it to the trust store:
    keytool -import -noprompt -trustcacerts -alias <AliasName> -file <certificate> -keystore <KeystoreFile> -storepass <Password>
  5. Check the trust store to see your certitifcate: keytool -list -keystore "%JAVA_HOME%/jre/lib/security/cacerts"

Here is a reference for trust store and certificates in Oracle JDK: https://docs.oracle.com/javase/tutorial/security/toolsign/rstep2.html

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.