When building with Maven or Gradle, the dependency download process is failing because Java does not trust any of their SSL certs on Windows. Is there anyway to make Java trust the certificates from the Maven repositories?
Thanks in advance
There are multiple ways to do this.
1) You can add all the CA and intermediate certicate of the maven repository to your Java trust store using keytool command. You can do this by
openssl s_client -showcerts -connect <SERVER>:443 </dev/null 2>/dev/null|openssl x509 -outform PEM >certificate.pem
This will save the certicate in local file called cert.pem Now you have add this certiicate to your trust store conver to .der format
openssl x509 -outform der -in certificate.pem -out certificate.der
add to trust store.
keytool -import -alias your-alias -keystore cacerts -file certificate.der
2) If you want to by pass the trust you could use the following property while runing mvn. -Dmaven.wagon.http.ssl.insecure=true
3) If you are planning to by pass the Java Trsut store and want to your own trust store you could set the MAVEN_OPTS environment variable
MAVEN_OPTS="-Xmx512m -Djavax.net.ssl.trustStore=trust.jks \
-Djavax.net.ssl.trustStorePassword= \
-Djavax.net.ssl.keyStore=/home/directory/mycertificate.p12 \
-Djavax.net.ssl.keyStoreType=pkcs12 \
-Djavax.net.ssl.keyStorePassword=XXXXXX"
reference : https://maven.apache.org/guides/mini/guide-repository-ssl.html