« Zurück

Fixing SunCertPathBuilderException caused by Maven downloading from self-signed repository

Company Blogs 11. August 2011 Von 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.

 

 

Antworten im Thread Autor Datum
This was useful even after 3+ years. Thanks Neil. Jack Bakker 22. Februar 2015 11:55
Hi Neil, i tried your suggestion but ended up... sathya m 5. November 2015 00:39
Hi, I have fixed the issue myself. just... sathya m 5. November 2015 00:54
Hi, can you please share the relative path... MEHARNATH BORIGI 17. November 2015 12:19
I'm trying to build a new Liferay Plugin... MEHARNATH BORIGI 17. November 2015 12:22
Error: Exception in thread "main"... MEHARNATH BORIGI 17. November 2015 12:23

This was useful even after 3+ years. Thanks Neil.
Gepostet am 22.02.15 11:55.
Hi Neil,

i tried your suggestion but ended up in Java error. I am not a Java person so i didn't understand much from this error. I am trying to fix SunCertPathBuilderException error when Jenkins try to download from Artifactory. We are running Maven build. Any help would be appreciated.

Error

[fx@jenkinsserver ~/jenkins-home/secrets] $ java com.aw.ad.util.InstallCert artifactory.serv.mycomp:443
Exception in thread "main" java.lang.NoClassDefFoundError: com/aw/ad/util/InstallCert
Caused by: java.lang.ClassNotFoundException: com.aw.ad.util.InstallCert
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: com.aw.ad.util.InstallCert. Program will exit.

ls -ltr
-rw-rw---- 1 fx fx 7562 Nov 5 19:28 InstallCert.java
-rw-rw---- 1 fx fx 1131 Nov 5 19:28 InstallCert$SavingTrustManager.class
-rw-rw---- 1 fx fx 5872 Nov 5 19:28 InstallCert.class
Gepostet am 05.11.15 00:39 als Antwort auf Jack Bakker.
Hi,

I have fixed the issue myself. just created dir com/aw/ad/util and copied the classes to it. emoticon

Thanks
Gepostet am 05.11.15 00:54 als Antwort auf Jack Bakker.
Hi,

can you please share the relative path where you have created the folders

Thanks
Mehar
Gepostet am 17.11.15 12:19 als Antwort auf sathya m.
I'm trying to build a new Liferay Plugin project in my local PC and received below error, help from anyone is highly appreciated. Seriously i don't what to use as hostname.

Thanks
Mehar
Gepostet am 17.11.15 12:22 als Antwort auf MEHARNATH BORIGI.
Error:

Exception in thread "main" 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
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1520)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:182)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:176)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker­.java:975)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.ja­va:123)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:511)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:449)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:817)
at­ com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl­.java:1029)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:105­6)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:104­0)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:405)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDe­legateHttpsURLConnection.java:170)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.jav­a:1841)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.jav­a:1176)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnect­ionImpl.java:234)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.wrapper.Install$1.call(Install.java:59)
at org.gradle.wrapper.Install$1.call(Install.java:46)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.­java:65)
at org.gradle.wrapper.Install.createDist(Install.java:46)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:285)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)
at sun.security.validator.Validator.validate(Validator.java:218)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.­java:126)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustMa­nagerImpl.java:209)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustMa­nagerImpl.java:249)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker­.java:954)
... 20 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder­.java:174)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:280)
... 26 more
Gepostet am 17.11.15 12:23 als Antwort auf MEHARNATH BORIGI.