[Solved-4 Solutions] javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed Error



Error Description:

We get this error

  • Detailed message sun.security.validator.ValidatorException: PKIX path building failed:
  • sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
  • cause javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Solution 1:

System.setProperty("javax.net.ssl.trustStore", "C:/.keystore");
    System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
click below button to copy the code. By - Java tutorial - team

Solution 2:

  • Set below in environment variable
    CATALINA_OPTS -- param name
    -Djavax.net.ssl.trustStore=C:\.keystore -Djavax.net.ssl.trustStorePassword=changeit ---param value

click below button to copy the code. By - Java tutorial - team

Solution 3:

  • Set below in environment variable
    JAVA_OPTS -- param name
    -Djavax.net.ssl.trustStore=C:\.keystore -Djavax.net.ssl.trustStorePassword=changeit ---param value
click below button to copy the code. By - Java tutorial - team

Solution 4:

  • You need to add the certificate for App2 to the truststore file of the used JVM located at %JAVA_HOME%\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"
  • 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>

click below button to copy the code. By - Java tutorial - team
  • After import you can run the first command again to check if your certificate was added.

Related Searches to javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed Error