sun security validator exception pkix path building failed
When it Happens
While doing maven build in intellij using maven tool bar. Not the build from intellij terminal which again calls command prompt

Why it Happens
Intellij has its own security store and java internally. So while doing build in case the security certificates are missing in inbuilt security keystore would result in the above error. Intellij java certificates are found in below location.Proxy certificates are not added to intellij keystore.

Fix

  1. The below should be done by running command prompt as administrator.
  2. Locate your network’s certificate: In a browser, navigate to “URL OF REPO” and then hit F12, go to certificates/security and get the top most certificate… Export it to MyCertificate.cer (base64 encoded)
  3. Navigate to security folder in intellij
    C:\Program Files\IntelliJ IDEA Community Edition 2019.3.4\jbr\lib\security
    
  4. Copy over MyCertificate.cer into the security folder
  5. Type “keytool -keystore cacerts -importcert -alias MyCertificate -file MyCertificate.cer” without quotes.
  6. Use the default password of “changeit”
  7. When prompted to trust the certificate type “yes”.Restart Intellij and try to run maven install again from maven to make sure the jars are imported

More Notes in above
We experienced this issue when a server changed their HTTPS SSL certificate, and our older version of Java did not recognize the root certificate authority (CA).

If you can access the HTTPS URL in your browser then it is possible to update Java to recognize the root CA.

In your browser, go to the HTTPS URL that Java could not access. Click on the HTTPS certificate chain (there is lock icon in the Internet Explorer, or the domain name left of the URL in firefox) and navigate the certificate hierarchy. At the top there should be a Primary Root CA. This could be missing from your java cacerts file. Note down the Issuer and Serial Number.