sun.security.validator.ValidatorException: PKIX pa

2019-09-14 08:09发布

问题:

I have a Java JAR application which connects to the Java web service running on a server behind HTTPS. If I run the JAR with Oracle Java 1.6, then the SSL handshake is successful. However, If I run it with Oracle Java 1.7 or newer, I always get the exception: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I have imported the certificates to the cacert file, and have used VM variable javax.net.ssl.trustStore to set the path to the file.

I have found out that there are differences in jsse.jar in different Java version.

Also, this application works like expected on a Unix machine which has IBM version of Java installed: IBM J9 VM (build 2.7, JRE 1.7.0

And, it works correctly with IBM JRE on Widnows:

IBM J9 VM (build 2.8, JRE 1.8.0)

What could I do to fix this?

回答1:

I solved this! Java has java.security file in jre/lib/security folder, and that file has a property keystore.type. This property was set to Windows-ROOT, but I have imported certificates in cacerts file, and the property should be set to jks so that Java reads the cacerts file!