JetBrains / TeamCity.SonarQubePlugin

A plugin for TeamCity server allowing you to configure and run SonarQube analysis from the CI
Apache License 2.0
53 stars 31 forks source link

Execution Failure with HTTPS server #31

Closed renzors closed 6 years ago

renzors commented 7 years ago

Hello, I am having a problem with analyzer when have changed from http to https sonarqube server. This is my trace error:

[13:59:16][Step 9/9] INFO: Work directory: C:\BuildAgent\work\4f17f361fd9d251b\.\.sonar [13:59:16][Step 9/9] INFO: ------------------------------------------------------------------------ [13:59:16][Step 9/9] INFO: EXECUTION FAILURE [13:59:16][Step 9/9] INFO: ------------------------------------------------------------------------ [13:59:16][Step 9/9] Total time: 0.407s [13:59:16][Step 9/9] Final Memory: 4M/107M [13:59:16][Step 9/9] INFO: ------------------------------------------------------------------------ [13:59:16][Step 9/9] ERROR: Error during Sonar runner execution [13:59:16][Step 9/9] org.sonar.runner.kevinsawicki.HttpRequest$HttpRequestException: javax.net.ssl.SSLHandshakeException: Received fatal alert: unrecognized_name [13:59:16][Step 9/9] at org.sonar.runner.kevinsawicki.HttpRequest.code(HttpRequest.java:1392) [13:59:16][Step 9/9] at org.sonar.runner.kevinsawicki.HttpRequest.ok(HttpRequest.java:1417) [13:59:16][Step 9/9] at org.sonar.runner.impl.ServerConnection.downloadString(ServerConnection.java:93) [13:59:16][Step 9/9] at org.sonar.runner.impl.ServerVersion.downloadVersion(ServerVersion.java:47) [13:59:16][Step 9/9] at org.sonar.runner.impl.ServerVersion.version(ServerVersion.java:38) [13:59:16][Step 9/9] at org.sonar.runner.impl.ServerVersion.is37Compatible(ServerVersion.java:58) [13:59:16][Step 9/9] at org.sonar.runner.impl.JarDownloader.checkVersionAndDownload(JarDownloader.java:36) [13:59:16][Step 9/9] at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:71) [13:59:16][Step 9/9] at java.security.AccessController.doPrivileged(Native Method) [13:59:16][Step 9/9] at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) [13:59:16][Step 9/9] at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) [13:59:16][Step 9/9] at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102) [13:59:16][Step 9/9] at org.sonar.runner.api.Runner.execute(Runner.java:100) [13:59:16][Step 9/9] at org.sonar.runner.Main.executeTask(Main.java:70) [13:59:16][Step 9/9] at org.sonar.runner.Main.execute(Main.java:59) [13:59:16][Step 9/9] at org.sonar.runner.Main.main(Main.java:53) [13:59:16][Step 9/9] Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: unrecognized_name [13:59:16][Step 9/9] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [13:59:16][Step 9/9] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [13:59:16][Step 9/9] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [13:59:16][Step 9/9] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [13:59:16][Step 9/9] at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1890) [13:59:16][Step 9/9] at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1885) [13:59:16][Step 9/9] at java.security.AccessController.doPrivileged(Native Method) [13:59:16][Step 9/9] at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1884) [13:59:16][Step 9/9] at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1457) [13:59:16][Step 9/9] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) [13:59:16][Step 9/9] at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480) [13:59:16][Step 9/9] at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338) [13:59:16][Step 9/9] at org.sonar.runner.kevinsawicki.HttpRequest.code(HttpRequest.java:1390) [13:59:16][Step 9/9] ... 15 more [13:59:16][Step 9/9] Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: unrecognized_name [13:59:16][Step 9/9] at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) [13:59:16][Step 9/9] at sun.security.ssl.Alerts.getSSLException(Alerts.java:154) [13:59:16][Step 9/9] at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023) [13:59:16][Step 9/9] at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125) [13:59:16][Step 9/9] at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) [13:59:16][Step 9/9] at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) [13:59:16][Step 9/9] at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) [13:59:16][Step 9/9] at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) [13:59:16][Step 9/9] at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) [13:59:16][Step 9/9] at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513) [13:59:16][Step 9/9] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) [13:59:16][Step 9/9] at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2943) [13:59:16][Step 9/9] at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderField(HttpsURLConnectionImpl.java:291) [13:59:16][Step 9/9] at org.sonar.runner.kevinsawicki.HttpRequest.header(HttpRequest.java:1903) [13:59:16][Step 9/9] at org.sonar.runner.kevinsawicki.HttpRequest.contentType(HttpRequest.java:2308) [13:59:16][Step 9/9] at org.sonar.runner.impl.ServerConnection.downloadString(ServerConnection.java:89) [13:59:16][Step 9/9] ... 13 more [13:59:16][Step 9/9] Process exited with code 1

I have seen a fix, and I should disable SNI for Java by adding the -Djsse.enableSNIExtension=false. But I don't know in that part of my teamcity agent I should set this option or if I should set it in plugin.

Linfar commented 7 years ago

@renzors To pass parameters to the JVM Sonar is running on you could add env.SONAR_SCANNER_OPTS parameter with "-Djsse.enableSNIExtension=false" value to your configuration. If you're using old SonarQube version SONAR_RUNNER_OPTS variable should be used.

renzors commented 7 years ago

@Linfar Thanks for your response. I am using SonarQube 6.0 and I have tried the configuration but it still is failing. I send some captures:

image

The build log error is the same. Do you need more information?

Thanks in advance for your support.

Linfar commented 7 years ago

Please try the second parameter (with Sonar runner). If it won't help please send me a build log - better to andrey.titov@jetbrains.com

Linfar commented 7 years ago

Any update?

renzors commented 7 years ago

HI @Linfar when we made the change but get the same error. For now, we have set the server with the IP number and http protocol and it is working fine. If you want, I can send you the build log to your analysis.

Linfar commented 7 years ago

@renzors The problem lies in SSL configuration. Java tries to verify the hostname with certificate installed in SonarQube server and fails. It seems SonarQube doesn't allow disabling SNI (Server Name Indication) so I see 2 options:

  1. Continue using HTTP
  2. Fix SSL configuration You can try to run SonarQube Runner on the agent machine (under the same user as Build Agent and using same java installation). If it will fail with same exception - I can't help from my side.
Linfar commented 6 years ago

I will close this ticket to clean the tracker