Failed to request and parse error message for sonarscanner while fetching the analysis configuration settings from sonarQube

Hello,

I am running sonarqube in docker container in my linux machine. And my sonar-scanner is running on another machine which is Windows VM. I have configured the sonarqube in my Jenkins pipeline and trying to run the pipeline, however I am getting below error message everytime.

SonarScanner for MSBuild 4.6
Using the .NET Core version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories…
15:46:27.847 Updating build integration targets…
15:46:27.925 Fetching analysis configuration settings…
15:46:28.068 Failed to request and parse ‘https://test.sonarqube.com/api/server/version ’: An error occurred while sending the request. A security error occurred

Unhandled Exception: System.Net.WebException: An error occurred while sending the request. A security error occurred —> System.Net.Http.HttpRequestException: An error occurred while sending the request. —> System.Net.Http.WinHttpException: A security error occurred

I am able to get the SonarQ version when I hit this url in browser - https://test.sonarqube.com/api/server/version, however seems to be an issue for sonarscanner to get the expected version as output.

My sonarqube is running on https and also its behind the Nginx reverse proxy.

I also tried passing my proxy configurations to SONAR_SCANNER_OPTS env variable on my sonar scanner instance, however I am still getting the same error message as mentioned above(Failed to request and parse). And I also tried adding the sonarqube ssl certificate into the Jenkins Java Truststore file, still getting the same above error.

I am using below versions -
Sonarqube version - 7.9 LTS version
Sonarscanner version - 3.0.3.778

Could you please help me here to resolve this issue?

Hi,

Googling System.Net.WebException led me to this

This looks like an intermittent networking error. I’m thinking these errors might happen when your server can’t talk to ours correctly.

Which confirmed my initial suspicion that this is about what’s on your network between the analysis machine and the SonarQube server. You need to talk to your network folks.

 
HTH,
Ann

Hi Ann,

Thanks for your reply.

I also googled for HttpWebRequest.Host throw WebException and it led me to this

If you really want to talk with a server and disregard TLS/SSL certificate errors (such as name mismatch in this case), then please take a look at using this API for HttpWebRequest. To accept SSL:
request.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

I am using .Net version 3.1.300 and sonarscanner for MSBuild version - 4.6.0.1930 - .NET core 2.0
I am not sure, where I need to add the above line, to accept SSL.

Could you please check if you have any idea?