Maven build failed - PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed - Mac

Viewed 6293

I am trying a build code a using maven in mac machine but it is getting failed with following error message

PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed: NotAfter: Thu Apr 01 00:59:59 BST 2021

Tried to uninstall and install JDK but this did not help. Also I tried to check cert file in /Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home/jre/lib/security but there is no file related cert. Any input would be appreciated greatly

2 Answers

validity check failed: NotAfter: Thu Apr 01 00:59:59 BST 2021

It is clear : the certificate has expired because today we are after the 01 April 2021.
To fix the problem :

  • either ask to the certificate publisher/owner to provide a new one with a valid date.
  • or run Maven in a way where it will ignore the certificate validity date.

For the latter (with clean package goal for example) you can do :

mvn clean package -Dmaven.wagon.http.ssl.ignore.validity.dates=true

If you want to ignore completely all ssl verifications, you can set all these flags :

mvn clean package -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true

To not repeat the flags at every mvn command executed, you can also set the MAVEN_OPTS env variable such as :

MAVEN_OPTS="-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true"

Edit

To help diagnostic issue :

  1. see the content of a certificate with openssl (Linux or Mac) such as :

    openssl x509 -in foo.crt -noout -text

To see only dates (@dave_thompson_085) :

openssl x509 -in foo.crt -noout -dates

On Windows, openssl is not required since the file association of the crt should help.

  1. Make maven to run in debug verbosity (-X flag)

    mvn -X clean package

  2. Make maven to run with SSL logs enabled :

mvn -Djavax.net.debug=ssl clean package

You could even use all these flags :

mvn -X \
    -Djavax.net.debug=ssl \
    -Dmaven.wagon.http.ssl.insecure=true \
    -Dmaven.wagon.http.ssl.allowall=true \
    -Dmaven.wagon.http.ssl.ignore.validity.dates=true \
clean package 

Try Following things :-

  1. Check for communication if you are behind a firewall or port blocking
  2. SSL certificate if it hasn't expired
Related