Fixing SunCertPathBuilderException caused by Maven downloading from self-signed repository
Staff Blogs August 11, 2011 By Neil Griffin Staff
If you have a Maven repository running under https with a self-signed certificate, then building a Maven project can report the following error:
Error transferring file: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
There was an Oracle blog posted by Andreas Sterbenz back on Oct 09, 2006 that helped me diagnose the problem, but that blog is no longer available. Thankfully Andreas' blog was re-posted here. For additional information, I found another blog post that was helpful.
Anyways, I fixed this problem by downloading and compiling the source for InstallCert.java and running the following command:
java com.aw.ad.util.InstallCert myhostname.mydomain.com
This generated a file named jssecacerts in the current directory.
On Windows/Linux, this file needs to be copied to the JAVA_HOME/jre/lib/security/ directory.
On Mac needs to be copied to the JAVA_HOME/lib/security/ directory.
After I did this, Maven was able to download the artifacts from the self-signed repository.