Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij IDE giving PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException

I am getting error

22:00:17.222 [pool-6-thread-1] ERROR ingrian.internal.xml.XMLAuthToken - handshakeCompleted: SSL handshake did not complete within alloted time {}
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 sun.security.ssl.Alert.createSSLException(Alert.java:131) ~[?:1.8.0_351]

in my Intellij IDE, when I am running any Java file, but when I am running mvn clean install, the build is getting successful. I have added all the required certificates. mvn --version

Maven home: /usr/local/Cellar/maven/3.5.4/libexec
Java version: 1.8.0_351, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_351.jdk/Contents/Home/jre

IDE Run Config

IDE Run Config

Intellij was running fine, before, I replaced the old certs with the new certs and then it started giving this error.

I have downloaded new java version, new IDE version as well, cleared the old cache, but nothing seems to work.

Is there any configuration in Intellij that I have to update?

like image 557
AnxiousGuy Avatar asked Nov 01 '25 06:11

AnxiousGuy


1 Answers

I encountered this error while on Mac OS. My Issue was when trying to download dependencies located in https://repo.maven.apache.org/maven2/org/slf4j/slf4j-simple/2.0.7/slf4j-simple-2.0.7.pom from maven central while using Intellij Idea.

Steps to resolve:

  1. Visit https://repo.maven.apache.org/maven2/org/slf4j/slf4j-simple/2.0.7/slf4j-simple-2.0.7.pom on your browser.
  2. Click the lock icon as below [![enter image description here][1]][1] Go to Connection is secure then Certificate is valid.
  3. On the Details tab, select the top most on the certificate hierarchy and export to your known location on disk.

Next we are going to import the certificate on two keystores. First on our JDK keystore and later on the keystore used by the IDE.

Import on JDK keystore.

  1. Navigate to security folder on JAVA_HOME. For my case locate /Library/Java/JavaVirtualMachines/jdk-11.0.16.1.jdk/Contents/Home/lib/security. In this list you will see a file cacerts which is a collection of trusted certificates. we need to import our downloaded certificate here using the command sudo keytool -importcert -alias maven -file ~/Desktop/repo.maven.apache.org.cer -keystore cacerts. Note in my case I downloaded the certificate to trust on my Desktop folder and named repo.maven.apache.org.cer. When prompted enter you password as changeit for truststore.

  2. Next we need to trust the certificate within our IDE's security folder. cd /Applications/IntelliJ IDEA 19.05.39.app/Contents/jbr/Contents/Home/lib/security. Note my IDE's version as the location my change a bit based on the version of IDE you are using.

  3. Import the downloaded certificate using sudo keytool -importcert -alias maven -file ~/Desktop/repo.maven.apache.org.cer -keystore cacerts. Enter your user password when prompted and changeit for keystore password.

  4. Restart your IDE.

like image 179
Kipng'etich Victor Lang'at Avatar answered Nov 02 '25 21:11

Kipng'etich Victor Lang'at