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

If you are trying to download Maven dependencies from Artifactory and encounter an error “PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target”

It’s because JVM does not trust Artifcatory certificates. So all you need to do to fix it is to export the Artifactory certificates using browser and import it in JVM keystore executing following command after moving to $JAVA_HOME/jre/lib/security:

$ cd $JAVA_HOME/jre/lib/security

$ keytool -import -trustcacerts -alias JFrogArtifactory -file /Users/ArpitAggarwal/jfrog-artifactory.cer -keystore cacerts -storepass changeit

jfrog-artifactory.cer specified above is the artifactory certificate exported using browser.

cacerts specified above is the JVM truststore.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s