Found this weird error when connecting to a HTTPS website, using apache commons httpclient.
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
Very weird because i can connect to almost every other HTTPS website, but only one website causing this exception. After googling for a while, i found a very interesting solution from MKYong, that is to register the website’s certificate on my JVM.
http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/
Run this command to generate a new jssecacerts file,
c:\>java InstallCert localhost:443
The only difference is the location where i downloaded InstallCert.java, i downloaded it from this link.
https://github.com/OopsMouse/java-use-examples/blob/master/src/com/aw/ad/util/InstallCert.java
And i also removed the file’s package name, to make it easier to run.