Maven and Keytool

Sometimes using Maven you can have this error:

> Unable to load Maven meta-data from https://example.com/maven-metadata.xml.

> Could not HEAD ‘https://example.com/maven-metadata.xml’.

> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I resolve in this way:

  1. Download the cert of the site https://example.com/ using the browser
  2. Reset my keytool password as reported here https://docs.oracle.com/cd/E19957-01/817-3331/6miuccqo3/index.html (note the changeit password)
  3. sudo keytool -import -alias YOURALIAS -keystore $JAVA_HOME/jre/lib/security/cacerts -file file.crt

Where file.crt is the file downloaded at point 1)

Leave a Reply