Throwing SSLHandShakeException when running JAVA from gradle

Hello. I’m quite new with gradle and I’m trying to run a java class (gradle run) behind a proxy. If I run the class on the command line it works fine but with gradle I get a handshake_failure:

‘’’ javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)

at sun.security.ssl.Alerts.getSSLException(Alerts.java:154) ‘’’

I’ve checked system properties like proxies, certificates, truststore, keystore, version of java etc and they seem to be correct. So, what I might be doing wrong?

Also when I try to use the wrapper it still fails with the same Exception.

System properties: Java:1.8 Gradle: 2.0

Any help is highly appreciated! Many thanks

Hi Eleni

I’d check you are adding both the proxy properties to Gradle and to your JavaExec task.

Gradle requires its proxy settings set with System Properties or in a gradle.properties file as described in section 20.2 of the manual

When you use ‘gradle run’ it spawns off another JVM process separate from Gradle. This requires its system properties to be set separately using the ‘applicationDefaultJvmArgs’ property as described in example 45.2

Please let us know how you go.

Kind Regards

Kon

Hi Eleni

I’d check you are adding both the proxy properties to Gradle and to your JavaExec task.

Gradle requires its proxy settings set with System Properties or in a gradle.properties file as described in section 20.2 of the manual

When you use ‘gradle run’ it spawns off another JVM process separate from Gradle. This requires its system properties to be set separately using the ‘applicationDefaultJvmArgs’ property as described in example 45.2

Please let us know how you go.

Kind Regards

Kon

Hi Kon,

Many thanks for the reply.

I tried both but still fails with the same exception. In particular my gradle.build file is as follows: ‘’’ mainClassName = “my.MainClass” applicationDefaultJvmArgs = ["-Dhttp.proxyHost=www.my-poxy.com

-Dhttp.proxyPort=8080 -Dhttps.proxyHost=www.my-poxy.com

-Dhttps.proxyPort=8080 -Djavax.net.ssl.trustStore=/path/to/cacerts

-Djavax.net.ssl.keyStore=/path/to/keystore.p12

-Djavax.net.ssl.keyStorePassword=XXXX

-Djavax.net.ssl.keyStoreType=PKCS12"] ‘’’ And also I define those in the gradle.properties (saved on my project path and on the ~/.gradle): ‘’’ systemProp.proxySet=true systemProp.javax.net.ssl.trustStore=/path/to/cacerts systemProp.javax.net.ssl.keyStore=/path/to/.keystore.p12 systemProp.javax.net.ssl.keyStoreType=PKCS12 systemProp.javax.net.ssl.keyStorePassword=XXXX systemProp.http.proxyHost=www.my-poxy.com systemProp.http.proxyPort=8080 systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost ‘’’

I tried an alternative way which is to use the gradle wrapper (gradlew script). In the first line of that script I define the DEFAULT_JVM_OPTS with the above parameters but it also fails when i run it.

I think i decided to use a separate script for running and use gradle only for depedencies and tests.

Still i’m curious to find what might be the problem.

Many thanks, Eleni