Environment: Jenkins (running build on Windows Agent)
JDK: 21 (Corretto)
Gradle 8.14
Sonar Gradle Plugin 6.2.0.5505
Hi,
when running the “sonar” task with the Sonar Gradle Plugin (atleast for version 6+), I get the following keystore error:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':sonar'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:130)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:293)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:128)
...
Caused by: org.sonarqube.gradle.AnalysisException: nl.altindag.ssl.exception.GenericKeyStoreException: Unable to read truststore from 'D:\dev\.gradle\truststore'
at org.sonarqube.gradle.SonarTask.run(SonarTask.java:148)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:125)
...
Caused by: nl.altindag.ssl.exception.GenericKeyStoreException: Unable to read truststore from 'D:\dev\.gradle\truststore'
at org.sonarsource.scanner.lib.internal.http.OkHttpClientFactory.configureSsl(OkHttpClientFactory.java:146)
at org.sonarsource.scanner.lib.internal.http.OkHttpClientFactory.create(OkHttpClientFactory.java:80)
at org.sonarsource.scanner.lib.internal.http.ScannerHttpClient.init(ScannerHttpClient.java:52)
at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.bootstrap(ScannerEngineBootstrapper.java:147)
at org.sonarqube.gradle.SonarTask.run(SonarTask.java:134)
...
Caused by: java.security.KeyStoreException: Uninitialized keystore
at org.sonarsource.scanner.lib.internal.http.OkHttpClientFactory.configureSsl(OkHttpClientFactory.java:144)
at org.sonarsource.scanner.lib.internal.http.OkHttpClientFactory.create(OkHttpClientFactory.java:80)
at org.sonarsource.scanner.lib.internal.http.ScannerHttpClient.init(ScannerHttpClient.java:52)
at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.bootstrap(ScannerEngineBootstrapper.java:147)
at org.sonarqube.gradle.SonarTask.run(SonarTask.java:134)
(Stacktrace is truncated for better readability)
Contrary to the exception above, when checking the truststore using keytool, I could see that the truststore is initialized. This is supported by the fact that other tools, including the Sonar Gradle Plugin up to and including major version 5 can read this truststore without any problems.
I also checked other minor versions of the Sonar Gradle Plugin 6.x, but they all fail with the same KeyStoreException.
Thanks. I’m not sure what could be causing the issue then. I’ve flagged this for attention, but I suggest continuing to use v5 for now until it gets sorted out!
we’re currently using v5 as a workaround, but we probably have to drop that once Gradle 9 is released, since v5 is using lots of deprecated Gradle API that will be removed with Gradle 9.
Using the Sonar Maven plugin and JDK 21, I came up with the same issue with sonar-maven-plugin 5.1.0.4751 and sonar-maven-plugin 5.2.0.4988. However it works with sonar-maven-plugin 5.0.0.4389. My SonarQube server is v24.12.0.100206. Do you have any clue?
I am afraid you refer to the Sonar Gradle plugin, not to the Sonar Maven plugin. To my knowldege, 5.2.0.4988 is the latest version of the Sonar Maven plugin at this time.
the error message is “Unable to read truststore from ‘/path/to/file/jks’: Uninitialized keystore” and is pretty vague.
Now with
-Dsonar.scanner.truststorePath=/path/to/file/jks
(as per your suggestion) the error message becomes “Unable to read truststore from ‘/path/to/file/jks’: password incorrect or store tampered with”, which is significantly more indicative.
Adding also
-Dsonar.scanner.truststorePassword=“”
the error message becomes “BC JKS store is read-only and only supports certificate entries”.
And finally your colleague Julien Henry brilliantly provided the last bit here : by removing a private key that was lying in my .jks truststore, I ended making my “mvn sonar:sonar” command work with version 5.2 of the Maven plugin.