Is there any way to tell gradle, here is my certificate and use it in order to reach my artifactory?
There are solutions that insert certificate in the system or in Java Security.
But I wanted some better solution that will not require any setup from user side, after cloning my repository.
No, unfortunately I could not find any tutorial, but I solved with lots of Trial and Error.
Here I will try to explain steps in more details.
Export certificates of Your Artifactory
Open your artifactory in browser and export it (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).
Copied default ca file from Java/Security
Copy Keystore cacerts from /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/security/ (Note that this path will vary from machine to machine, depending on java version and other factors.
Added Certificates in ca file
Import exported certificate in cacerts using command keytool -import -alias yourartifactory.com -file exported_certificate.cer -keystore cacerts -storepass password
Copied ca file in Project
Place cacerts in project root directory.
Added DEFAULT_JVM_OPTS
Add jvm arguments org.gradle.jvmargs=-Djavax.net.ssl.trustStore="./cacerts" -Djavax.net.ssl.trustStorePassword=password
in gradle.properties file.
the default java cacerts password is changeit
Tested with oracle jdk 171.
the command in point 2 should be
keytool -import -alias yourartifactory.com -file exported_certificate.cer -keystore cacerts -storepass changeit