Thursday, May 25, 2023

mvn clean install is giving error "PKIX path building failed. unable to find valid certification path"

Issue: When trying to execute "maven clean install", I am getting an error message saying "PKIX path building failed. unable to find valid certification path"

Reasons:

  • Certificates to the nexus repository are not imported to JDK trust store. To do this follow the below steps
    • Open the nexus url in chrome browser
    • Click on lock button in the address bar to the left of the url.
    • Click "Connection is secure". 
    • Click "Certificate is valid".
    • Go to tab "Details"
    • Export the certificate to some local path say "/Users/asood/Downloads/www.amazon.in.cer" 
    • Find the installation path of the jdk 
    • Navigate to lib/security directory
    • Import the above certificate into cacerts truststore using command
      • keytool -import -alias myalias -file /Users/asood/Downloads/www.amazon.in.cer -keystore cacerts
    • Try mvn clean install again and it should be ok now
  • The jdk used by maven is different from the default jdk home set for the machine. To check this follow the below steps
    • Run command 
      • mvn --version
    • Confirm if the jdk path is same as that being used default jdk home.
    • If not, there are 2 options
      1. Change the path of java used by maven to be same as the default jdk home
      2. Add the certificates to the lib/security/cacerts by following the steps mentioned above 


No comments:

Post a Comment

SpringBoot Application Event Listeners

When a spring boot application starts few events occurs in below order ApplicationStartingEvent ApplicationEnvironmentPreparedEvent Applicat...