Sonar-scanner fails with self-signed certificate

We’re using Sonar-Scanner with OpenJDK 1.8.0_212.

I’ve configured SonarQube (7.5) behind an AWS Loadbalancer to redirect http to https using a self signed Certificate (without an own or valid CA).

I have imported the crt file into the JVM Cacerts and also created a jks file containing the certificate.

No matter how I try, I alway get the following error:

INFO: SonarQube Scanner
INFO: Java 1.8.0_212 Oracle Corporation (64-bit)
INFO: Linux 4.15.0-1032-aws amd64
DEBUG: keyStore is :
DEBUG: keyStore type is : jks
DEBUG: keyStore provider is :
DEBUG: init keystore
DEBUG: init keymanager of type SunX509
DEBUG: Create: /var/jenkins_home/.sonar/cache
INFO: User cache: /var/jenkins_home/.sonar/cache
DEBUG: Create: /var/jenkins_home/.sonar/cache/_tmp
DEBUG: Extract sonar-scanner-api-batch in temp...
DEBUG: Get bootstrap index...
DEBUG: Download:
ERROR: SonarQube server [] can not be reached
INFO: ------------------------------------------------------------------------
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.319s
INFO: Final Memory: 5M/477M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
 at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(
 at Method)
 at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(
 at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(
 at org.sonarsource.scanner.api.EmbeddedScanner.doStart(
 at org.sonarsource.scanner.api.EmbeddedScanner.start(
 at org.sonarsource.scanner.cli.Main.execute(
 at org.sonarsource.scanner.cli.Main.main(
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
 at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(
 at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(
 at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(
 ... 7 more
Caused by: Hostname not verified:
    certificate: sha256/6h6rxxxxxxxxxxxxxxxxxxxxxxxxGB/y/hxxxxxxxxx=
    DN:,, OU=myOrgUnit, O=MyCompany, L=MyCity, ST=MyDistrict, C=AT
    subjectAltNames: []
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectTls(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.establishProtocol(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connect(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.findConnection(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.findHealthyConnection(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.StreamAllocation.newStream(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(
 at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(
 at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(
 at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(
 at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(
 ... 10 more    

The certificate is definitely correct and also the JKS was created correct as I tried a

curl --cacert

and have even written a small Java Class, which requests using the JKS File. Both work without any problems.

The JKS File is also taken correct from sonar-scanner as I tried to provide an invalid password or invalid JKS Location which leads into the following error:

Non-Existing JKS File:

Caused by: java.lang.RuntimeException: Unexpected error: the trustAnchors parameter must be non-empty

Invalid JKS password:

java.lang.AssertionError: problem accessing trust Keystore was tampered with, or password was incorrect

I also tried to use the command line parameters and instead of the SONAR_SCANNER_OPTS (and both) without any effect.

Changing to another scanner (Gradle, Maven) is currently no option.

Any help woud be appreciated


From my experience sonar-scanner has a bundled jre (and i don’t know why)
So you have to install you cert in that bundled java truststore. (been there too)

Hi @andgru ,

thx for response.
I use the “sonarqube scanner” Tool from Jenkins which does not have it’s own JRE.
Nevertheless I found out, that it uses okhttp API which needs a separate implementation for self signed certificates which I guess was not implemented.

If you need OkHttpClient to accept self signed SSL, you need to pass it custom instance via setSslSocketFactory(SSLSocketFactory sslSocketFactory) method. -->


I am having the same problem and also managed to import the certificate into the keystore - So it works :slight_smile: . However my feeling is that this is s pretty complicated thing and not very handy.

So what to you think about adding a flag to the sonarcube client (–ignore-ssl-error) to ignore SSL errors. For my use case, where we are using sonarcube only internal with self signed certificates but not want to miss encryption such a flag would be nice to have. What do you think?



(edit) Some distributions of sonar-scanner have a bundled JRE. The reasons behind it can be found here:

In the past we had an option to bypass checking the server certificate. This was dropped at one point since it’s an obvious security vulnerability. We have no plans to bring that option back.
The correct way is indeed to install the server’s certificate in the truststore if needed and if the server is authenticating the client by checking it’s certificate, it needs to be imported into the keystore.
This is not simple but the sonar-scanner relies on the standard mechanism in Java.

1 Like

Are you sure? You have OS-specific downloads with a bundled JRE… :wink:

You’re right, I’ll correct my post, thanks.

Update: I fixed this issue by adding SAN to the self signed Certificate.

That’s definitely the stupidest thing I’ve read today after wasting 2 days trying to get it work…
Like the alternatives would be really better. Especially when using sonar-scanner in docker container where you have absolutely no rights to change sonar-scanner truststore…
It should be up to users how they wan’t to connect to the sonar server. Especially the option to bind external trust store with was useful. Pretty legit solution. Now only option is to unsecure the route and use plain http. As requesting the certificate for development purposes in this case makes no sense.


This forum is a place for polite and constructive community discussions. The FAQ is at your disposal for guidelines on how to behave on this forum. Please feel free to review them, and consider this a warning.

Best regards,