SonarQube server can not be reached after upgrading sonar-scanner-cli from 4.7 to 5.0.1

Hi All,

For one of my projects we use the SonarScanner CLI. Previously we have been running the 4.7v and it worked flawlessly, but now that I have upgraded to the latest which is 5.0.1v I get the following error.

2024-05-10 16:10:50,523	[STDOUT]	(4065108) 16:10:50.523 INFO: SonarScanner 5.0.1.3006
2024-05-10 16:10:50,523	[STDOUT]	(4065108) 16:10:50.523 INFO: Java 17.0.7 Eclipse Adoptium (64-bit)
2024-05-10 16:10:50,523	[STDOUT]	(4065108) 16:10:50.523 INFO: Linux 5.15.0-91-generic amd64
2024-05-10 16:10:50,686	[STDOUT]	(4065108) 16:10:50.685 DEBUG: keyStore is : 
2024-05-10 16:10:50,686	[STDOUT]	(4065108) 16:10:50.685 DEBUG: keyStore type is : pkcs12
2024-05-10 16:10:50,686	[STDOUT]	(4065108) 16:10:50.686 DEBUG: keyStore provider is : 
2024-05-10 16:10:50,686	[STDOUT]	(4065108) 16:10:50.686 DEBUG: init keystore
2024-05-10 16:10:50,686	[STDOUT]	(4065108) 16:10:50.686 DEBUG: init keymanager of type SunX509
2024-05-10 16:10:50,811	[STDOUT]	(4065108) 16:10:50.810 DEBUG: Create: <path>/.sonar/cache
2024-05-10 16:10:50,811	[STDOUT]	(4065108) 16:10:50.811 INFO: User cache: <path>/.sonar/cache
2024-05-10 16:10:50,811	[STDOUT]	(4065108) 16:10:50.811 DEBUG: Create: <path>/.sonar/cache/_tmp
2024-05-10 16:10:50,813	[STDOUT]	(4065108) 16:10:50.813 DEBUG: Extract sonar-scanner-api-batch in temp...
2024-05-10 16:10:50,816	[STDOUT]	(4065108) 16:10:50.816 DEBUG: Get bootstrap index...
2024-05-10 16:10:50,816	[STDOUT]	(4065108) 16:10:50.816 DEBUG: Download: https://<domain name>/batch/index
2024-05-10 16:10:50,960	[STDERR]	(4065108) 16:10:50.960 ERROR: SonarQube server [https://<domain name>] can not be reached
2024-05-10 16:10:50,960	[STDOUT]	(4065108) 16:10:50.960 INFO: ------------------------------------------------------------------------
2024-05-13 12:06:58,390	[STDOUT]	(2705819) 12:06:58.390 INFO: EXECUTION FAILURE
2024-05-13 12:06:58,390	[STDOUT]	(2705819) 12:06:58.390 INFO: ------------------------------------------------------------------------
2024-05-13 12:06:58,390	[STDOUT]	(2705819) 12:06:58.390 INFO: Total time: 0.284s
2024-05-13 12:06:58,400	[STDOUT]	(2705819) 12:06:58.400 INFO: Final Memory: 5M/34M
2024-05-13 12:06:58,400	[STDERR]	(2705819) 12:06:58.400 ERROR: Error during SonarScanner execution
2024-05-13 12:06:58,400	[STDOUT]	(2705819) 12:06:58.400 INFO: ------------------------------------------------------------------------
2024-05-13 12:06:58,400	[STDERR]	(2705819) org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	at org.sonarsource.scanner.cli.Main.main(Main.java:62)
2024-05-13 12:06:58,401	[STDERR]	(2705819) Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42)
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
2024-05-13 12:06:58,401	[STDERR]	(2705819) 	... 7 more
2024-05-13 12:06:58,402	[STDERR]	(2705819) Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.Alert.createSSLException(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.SSLHandshake.consume(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.HandshakeContext.dispatch(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.HandshakeContext.dispatch(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.TransportContext.dispatch(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.SSLTransport.decode(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.SSLSocketImpl.decode(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectTls(RealConnection.java:336)
2024-05-13 12:06:58,402	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.establishProtocol(RealConnection.java:300)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connect(RealConnection.java:185)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.Transmitter.newExchange(Transmitter.java:169)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:221)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:81)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:115)
2024-05-13 12:06:58,403	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:99)
2024-05-13 12:06:58,404	[STDERR]	(2705819) 	at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:39)
2024-05-13 12:06:58,404	[STDERR]	(2705819) 	... 10 more
2024-05-13 12:06:58,404	[STDERR]	(2705819) Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
2024-05-13 12:06:58,404	[STDERR]	(2705819) 	at java.base/sun.security.validator.PKIXValidator.doBuild(Unknown Source)
2024-05-13 12:06:58,404	[STDERR]	(2705819) 	at java.base/sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
2024-05-13 12:06:58,404	[STDERR]	(2705819) 	at java.base/sun.security.validator.Validator.validate(Unknown Source)
2024-05-13 12:06:58,404	[STDERR]	(2705819) 	at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
2024-05-13 12:06:58,404	[STDERR]	(2705819) 	at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
2024-05-13 12:06:58,404	[STDERR]	(2705819) 	... 45 more
2024-05-13 12:06:58,404	[STDERR]	(2705819) Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
2024-05-13 12:06:58,404	[STDERR]	(2705819) 	at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
2024-05-13 12:06:58,404	[STDERR]	(2705819) 	at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
2024-05-13 12:06:58,404	[STDERR]	(2705819) 	at java.base/java.security.cert.CertPathBuilder.build(Unknown Source)
2024-05-13 12:06:58,404	[STDERR]	(2705819) 	... 50 more
2024-05-13 12:06:58,422	[ERROR]	####################################################################
2024-05-13 12:06:58,422	[ERROR]	12:06:58.389 ERROR: SonarQube server [https://<domain name>] can not be reached
12:06:58.400 ERROR: Error during SonarScanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
	at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)
	at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
	at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
	at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42)
	at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)
	at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
	... 7 more
Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at java.base/sun.security.ssl.Alert.createSSLException(Unknown Source)
	at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
	at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
	at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(Unknown Source)
	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(Unknown Source)
	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(Unknown Source)
	at java.base/sun.security.ssl.SSLHandshake.consume(Unknown Source)
	at java.base/sun.security.ssl.HandshakeContext.dispatch(Unknown Source)
	at java.base/sun.security.ssl.HandshakeContext.dispatch(Unknown Source)
	at java.base/sun.security.ssl.TransportContext.dispatch(Unknown Source)
	at java.base/sun.security.ssl.SSLTransport.decode(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl.decode(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectTls(RealConnection.java:336)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.establishProtocol(RealConnection.java:300)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connect(RealConnection.java:185)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.Transmitter.newExchange(Transmitter.java:169)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:221)
	at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:81)
	at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:115)
	at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:99)
	at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:39)
	... 10 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at java.base/sun.security.validator.PKIXValidator.doBuild(Unknown Source)
	at java.base/sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
	at java.base/sun.security.validator.Validator.validate(Unknown Source)
	at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
	at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
	... 45 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
	at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
	at java.base/java.security.cert.CertPathBuilder.build(Unknown Source)
	... 50 more

My question is, is there any massive difference between 4.7 and 5.0.1 where I perhaps have to append a new sonarqube parameter or something along those lines? I wanted to look at the release notes, but they link me to a Jira board which was not much of help. In addition, this is ran in a docker environment and my Sonarqube Server is running on 9.9.1v and it seems to be throwing this error only when running 5.0.1 and not 4.7.

Much thanks

anyone know please?

Hi,

This isn’t about the scanner version but about your SSL certificates. When you upgraded the server, I suppose you jumped from Java 11 to Java 17 too. You need to get your certificate chain imported into the new JVM’s trust store. The docs should help.

 
Ann

Hi Ann,

I never upgraded my server, only the scanner cli. The only difference is that for 4.7 sonar scanner we use Java 11 while for 5.0.1 we use Java 17, but I assume SSL certificates are still the issue? I’ll update the new JVM’s trust store and let you know if it fixes it or not.

Many thanks

Due to upgrading Java from 11 to 17, Java17 keystore did not have my cert so as Ann suggested, all I had to do is import my existing cert into the JVM’s trust store (/jre/lib/security/cacerts) with the command keytool -importcert -file <cert_name>.crt -keystore cacerts -alias "whatever_alias_you_have_named_it"