I want to specify a keystore and cert using the gradle.properties for a gradle application launched from the tooling api (GradleScriptRunner) but the properties are ignored or not used and i get aan exception : Caused by: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
I also tried passing the args to the tooling api manually but nothing changed
The application works fine when launched with the same properties file using the normal gradle script. My gradle.properties is placed in the /.gradle directory.
Can you confirm where you keep the gradle.properties file? What version of tooling api / gradle do you use? What happens if you avoid the ‘-b’ argument? (you can configure the project directory on the connector level).
Im testing this on a macosx and gradle.properties is in my home gradle directory e.g /Users/username/.gradle/gradle.properties. If as you say gradle.properties is not used when there is a -b argument I would expect the SSL properties to be used correctly. So lets ignore the gradle.properties file and assume i specify the SSL properties manually. I fixed one issue by removing the truststore and moving the public cert to the default truststore (cacerts). Now my config is simply:
During the dependency resolution stage I get a javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated excpetion, see below where i provide a more complete stacktrace which might be helpful.
4:29:03.243 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.api.UncheckedIOException: Could not GET 'https://repository.XXXXXX.com/maven2/com/XXXXX.pom'.
14:29:03.244 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.externalresource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:87)
14:29:03.244 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.externalresource.transport.http.HttpClientHelper.performRawGet(HttpClientHelper.java:64)
14:29:03.245 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.externalresource.transport.http.HttpClientHelper.performGet(HttpClientHelper.java:72)
14:29:03.245 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.externalresource.transport.http.HttpClientHelper.performGet(HttpClientHelper.java:68)
14:29:03.246 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.externalresource.transport.http.HttpResourceAccessor.getResource(HttpResourceAccessor.java:46)
14:29:03.247 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.externalresource.transfer.DefaultCacheAwareExternalResourceAccessor.getResource(DefaultCacheAwareExternalResourceAccessor.java:50)
14:29:03.247 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.repositories.DefaultExternalResourceRepository.getResource(DefaultExternalResourceRepository.java:62)
14:29:03.248 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.repositories.ExternalResourceResolver.getResource(ExternalResourceResolver.java:318)
14:29:03.248 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.repositories.ExternalResourceResolver.findStaticResourceUsingPattern(ExternalResourceResolver.java:257)
14:29:03.249 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.repositories.ExternalResourceResolver.findResourceUsingPattern(ExternalResourceResolver.java:243)
14:29:03.249 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.repositories.ExternalResourceResolver.findResourceUsingPatterns(ExternalResourceResolver.java:145)
14:29:03.250 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.repositories.MavenResolver.findIvyFileRef(MavenResolver.java:122)
14:29:03.251 [ERROR] [org.gradle.BuildExceptionReporter]
at org.apache.ivy.plugins.resolver.BasicResolver.getDependency(BasicResolver.java:223)
14:29:03.252 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DependencyResolverAdapter.getDependency(DependencyResolverAdapter.java:102)
14:29:03.253 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CacheLockingModuleVersionRepository$1.create(CacheLockingModuleVersionRepository.java:51)
14:29:03.253 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CacheLockingModuleVersionRepository$1.create(CacheLockingModuleVersionRepository.java:49)
14:29:03.254 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:172)
14:29:03.255 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:107)
14:29:03.255 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.longRunningOperation(DefaultCacheLockingManager.java:57)
14:29:03.256 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CacheLockingModuleVersionRepository.getDependency(CacheLockingModuleVersionRepository.java:49)
14:29:03.256 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository.resolveModule(CachingModuleVersionRepository.java:157)
14:29:03.257 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository.findModule(CachingModuleVersionRepository.java:94)
14:29:03.257 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository.getDependency(CachingModuleVersionRepository.java:85)
14:29:03.258 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.IvyContextualiser$1.invoke(IvyContextualiser.java:44)
14:29:03.258 [ERROR] [org.gradle.BuildExceptionReporter]
at $Proxy36.getDependency(Unknown Source)
14:29:03.259 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain.findLatestModule(UserResolverChain.java:73)
14:29:03.260 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain.resolve(UserResolverChain.java:54)
14:29:03.260 [ERROR] [org.gradle.BuildExceptionReporter]
... 103 more
14:29:03.261 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
14:29:03.261 [ERROR] [org.gradle.BuildExceptionReporter]
at com.sun.net.ssl.internal.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:352)
14:29:03.262 [ERROR] [org.gradle.BuildExceptionReporter]
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
14:29:03.262 [ERROR] [org.gradle.BuildExceptionReporter]
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:397)
14:29:03.263 [ERROR] [org.gradle.BuildExceptionReporter]
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
14:29:03.263 [ERROR] [org.gradle.BuildExceptionReporter]
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
14:29:03.264 [ERROR] [org.gradle.BuildExceptionReporter]
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
14:29:03.264 [ERROR] [org.gradle.BuildExceptionReporter]
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
14:29:03.264 [ERROR] [org.gradle.BuildExceptionReporter]
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
14:29:03.265 [ERROR] [org.gradle.BuildExceptionReporter]
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
14:29:03.265 [ERROR] [org.gradle.BuildExceptionReporter]
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
14:29:03.265 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.externalresource.transport.http.HttpClientHelper.performHttpRequest(HttpClientHelper.java:120)
14:29:03.266 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.externalresource.transport.http.HttpClientHelper.executeGetOrHead(HttpClientHelper.java:94)
14:29:03.266 [ERROR] [org.gradle.BuildExceptionReporter]
at org.gradle.api.internal.externalresource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:85)
14:29:03.267 [ERROR] [org.gradle.BuildExceptionReporter]
... 129 more
It could be that the HTTP library is not using the cacert or the SSL private key is not being used. Let me know if I can provide any more information.
That could be the issue but then i would expect that if i launch the wrapper script with the keyStore properties then the arguments wont be picked up by the daemon process launched by the tooling API.
The reason for the wrapper script in the first place is so that i can run the application inside my IntelliJ IDE.
There’s no doubt that the tooling API should handle this properly. We have to add special handling for system properties that are immutable, and currently we don’t treat the keystore properties as immutable.
I haven’t found anything conclusive, but I’ve seen some posts saying these properties need to be set at JVM startup time. The next thing we need to do is confirm this.
I noticed one strange thing, running a build from the command line used the gradle cache for the https dependency but when i launched a build from the wrapper script the cache was not used and I was back to the SSLPeerUnverifiedException.