Sometimes we need to use repos by self signed certs. Even Though you import self sign cert on your jvm. Gradle ignore to use keystore. The issues is mostly likely “Exception in thread “main” javax.net.ssl.SSLHandshakeException” or packages that can’t be downloaded because of an invalid certificate.
To be able to use self signed cert repo you should follow these steps:
Export certificates of Your Artifactory
Open your artifactory in browser and export its certificate (in order to get certificate from chrome browser open console, move to security tab and click view certificates, after that you will be able to export by dragging certificate icon to desktop).
Import self signed cert to cacerts keystore
keytool -import -trustcacerts -alias mvn -file <self-signed-cert-file> -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit
Add JVM params on gradle.properties file
On the project’s root directory create or edit the gradle.properties file and add the line below.
org.gradle.jvmargs=-Djavax.net.ssl.keyStore=“$JAVA_HOME/jre/lib/security/cacerts” -Djavax.net.ssl.keyStoreType=KeychainStore -Djavax.net.ssl.keyStorePassword=changeit
Now you are ready to use self signed maven repo.
Talat Uyarer 3 Nisan 2020