1

I want to run a SonarQube analysis of a .NET project.

I have set up a docker image with the prerequisites described here.

When following the instructions:

mono /msbuild/SonarQube.Scanner.MSBuild.exe begin /d:sonar.login=<my-sonarqube-secret-token> /k:somenameipasshere
SonarQube Scanner for MSBuild 4.0.2
Default properties file was found at /msbuild/SonarQube.Analysis.xml
Loading analysis properties from /msbuild/SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
16:49:01.29  Updating build integration targets...
16:49:01.305  Fetching analysis configuration settings...
16:49:01.433  Failed to request and parse 'https://myserver.sonarqube.local/api/server/version': Error: TrustFailure (One or more errors occurred.)
16:49:01.433  A server certificate could not be validated. Possible cause: you are using a self-signed SSL certificate but the certificate has not been installed on the client machine. Please make sure that you can access https://myserver.sonarqube.local without encountering certificate errors.
16:49:01.434  Pre-processing failed. Exit code: 1

... but

# keytool -import -file /sonar-scanner/certs/myserver.sonarqube.local.crt -keystore /sonar-scanner/jre/lib/security/cacerts     -alias myserver.sonarqube.local -storepass <somepass> -noprompt 
keytool error: java.lang.Exception: Certificate not imported, alias <myserver.sonarqube.local> already exists
G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
pkaramol
  • 16,451
  • 43
  • 149
  • 324

1 Answers1

3

Apparently MSBuild scanner does not operate with keytool as is the case with sonar-scanner.

One has to go through the typical (debian/ubuntu) process of copying the CA certs used by the server to /usr/local/share/ca-certificates/ and run sudo update-ca-certificates.

Secure communication is then possible with the SonarQube server.

pkaramol
  • 16,451
  • 43
  • 149
  • 324
  • `mono` also needs to trust the certificate. Depending on your distribution, you may need to add the `ca-certificates-mono` package. http://www.mono-project.com/docs/faq/security/ – Michael Weinand Mar 14 '18 at 15:41