javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed

I am connecting to a SSL site. This is one of the most frequent exceptions seen by a java developer.

To get rid of this, download the cert from the site you want to connect. Just click the lock sign near the browser URL. It will help you to download/export the SSL certificate to .cer format.

Import the certificate to your java cacerts.

I used OpenJDK

d:\java\jdk\bin\keytool -import -noprompt -trustcacerts -alias grassfield -file D:\gfield_ssl_cert.cer -keystore cacerts -storepass changeit
Certificate was added to keystore

You can list the certs in your cacerts store. I do a grep/find to get my cerficate.

d:\java\jdk\bin\keytool -list -keystore cacerts -storepass changeit|find “grassfield”
grassfield, Nov 25, 2019, trustedCertEntry,

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top