Good catch on the Path; the actual path is: “/d:sonar.scanner.truststorePath=C:\Users\boblinn.sonar\ssl\truststore.p12” and it does fail.
I started over having removed Sonar Extension from Visual Studio and leaving the previously installed local SonarServer but trying to access a different SonarServer URL.
Here’s the steps.
The error is shown in step 8 below for the ‘dotnet scanner begin’ step if I use the truststore.p12 OR jn step 10 below for the ‘dotnet scanner end’ step if I do not use the truststore.p12:
SonarQube Server: Version v9.9.8 (build 100196)
Installations steps as per https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/scanners/dotnet/installing/
Step 1. Open a Powershell terminal and navigate to my Visual Studio 2022 solution directory.
Step 2. Download the sonar scanner: “dotnet tool install --global dotnet-sonarscanner”
Result: “Tool ‘dotnet-sonarscanner’ is already installed.”
Step 3. Download and extract .Net Scanner “sonar-scanner-10.1.2.114627-net.zip” from here: https://github.com/SonarSource/sonar-scanner-msbuild/releases/tag/10.1.2.114627
Result: Extracted to folder “C:\SonarQube\sonar-scanner-10.1.2.114627-net”. This is my <INSTALL_DIRECTORY>
Step 4. Update the SonarQube.Analysis.xml file for the “sonar.host.url” and “sonar.token” properties.
Step 5. Add “C:\SonarQube\sonar-scanner-10.1.2.114627-net” to my PATH environment variable.
Add self-signed server certificate as per https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/scanners/scanner-environment/manage-tls-certificates/
Step 6. Create the directory C:\Users\boblinn.sonar\ssl" for the truststore keystore
Step 7. Add the truststore.p12 that I to my “C:\Users\boblinn.sonar\ssl” directory.
Step 8. Run the sonarscanner: If I run the scanner using the truststore.p12 with this Powershell command “dotnet sonarscanner begin /k:”" /d:sonar.host.url=[https://<host_url> /d:sonar.token=“***************” /d:sonar.scanner.scanAll=false /d:sonar.verbose=true" I get the following result.
Result:
SonarScanner for MSBuild 10.1.2
Using the .NET Core version of the Scanner for MSBuild
Default properties file was found at C:\Users\boblinn.dotnet\tools.store\dotnet-sonarscanner\10.1.2\dotnet-sonarscanner\10.1.2\tools\netcoreapp3.1\any\SonarQube.Analysis.xml
Loading analysis properties from C:\Users\boblinn.dotnet\tools.store\dotnet-sonarscanner\10.1.2\dotnet-sonarscanner\10.1.2\tools\netcoreapp3.1\any\SonarQube.Analysis.xml
sonar.verbose=true was specified - setting the log verbosity to ‘Debug’
Pre-processing started.
Preparing working directories…
Using environment variables to determine the download directory…
10:58:04.821 Loading analysis properties from C:\Users\boblinn.dotnet\tools.store\dotnet-sonarscanner\10.1.2\dotnet-sonarscanner\10.1.2\tools\netcoreapp3.1\any\SonarQube.Analysis.xml
10:58:04.848 Server Url: https://<host_url>
10:58:04.848 Api Url: <host_url>/api/v2
10:58:04.848 Is SonarCloud: False
10:58:04.857 No truststore provided; attempting to use the default location.
10:58:04.887 Could not import the truststore ‘C:\Users\boblinn.sonar\ssl\truststore.p12’ with the default password at index 0. Reason: The specified network password is not correct.
10:58:04.894 Could not import the truststore ‘C:\Users\boblinn.sonar\ssl\truststore.p12’ with the default password at index 1. Reason: The specified network password is not correct.
10:58:04.895 Fall back on using the truststore from the default location at C:\Users\boblinn.sonar\ssl\truststore.p12.
10:58:04.903 sonar.verbose=true was specified - setting the log verbosity to ‘Debug’
10:58:04.911 Updating build integration targets…
10:58:04.915 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
10:58:04.916 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
10:58:04.916 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
10:58:04.917 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
10:58:04.917 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
10:58:04.918 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
10:58:04.918 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
10:58:04.921 Installed SonarQube.Integration.targets to C:\Users\boblinn\source\repos\SEAM\src\SanMar.Azure.FunctionApps.Instrumentation.sonarqube\bin\targets
10:58:04.922 Creating config and output folders…
10:58:04.924 Creating directory: C:\Users\boblinn\source\repos\SEAM\src\SanMar.Azure.FunctionApps.Instrumentation.sonarqube\conf
10:58:04.925 Creating directory: C:\Users\boblinn\source\repos\SEAM\src\SanMar.Azure.FunctionApps.Instrumentation.sonarqube\out
10:58:04.949 Failed to import the sonar.scanner.truststorePath file C:\Users\boblinn.sonar\ssl\truststore.p12: The specified network password is not correct.
Unhandled exception. System.Security.Cryptography.CryptographicException: The specified network password is not correct.
at System.Security.Cryptography.X509Certificates.X509CertificateLoader.ImportPfx(ReadOnlySpan1 data, ReadOnlySpan1 password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509CertificateLoader.LoadPkcs12NoLimits(ReadOnlyMemory1 data, ReadOnlySpan1 password, X509KeyStorageFlags keyStorageFlags, X509Certificate2Collection& earlyReturn)
at System.Security.Cryptography.X509Certificates.X509CertificateLoader.LoadPkcs12Collection(ReadOnlyMemory1 data, ReadOnlySpan1 password, X509KeyStorageFlags keyStorageFlags, Pkcs12LoaderLimits loaderLimits)
at System.Security.Cryptography.X509Certificates.X509CertificateLoader.LoadFromFile[T](String path, ReadOnlySpan1 password, X509KeyStorageFlags keyStorageFlags, Pkcs12LoaderLimits loaderLimits, LoadFromFileFunc1 loader)
at System.Security.Cryptography.X509Certificates.X509CertificateLoader.LoadPkcs12CollectionFromFile(String path, ReadOnlySpan`1 password, X509KeyStorageFlags keyStorageFlags, Pkcs12LoaderLimits loaderLimits)
at System.Security.Cryptography.X509Certificates.StorePal.FromBlobOrFile(ReadOnlySpan`1 rawData, String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate2Collection.Import(String fileName, String password, X509KeyStorageFlags keyStorageFlags)
at SonarScanner.MSBuild.PreProcessor.WebClientDownloaderBuilder.AddServerCertificate(String serverCertPath, String serverCertPassword)
at SonarScanner.MSBuild.PreProcessor.PreprocessorObjectFactory.g__CreateDownloader|2_0(String baseUrl, <>c__DisplayClass2_0&)
at SonarScanner.MSBuild.PreProcessor.PreprocessorObjectFactory.CreateSonarWebServer(ProcessedArgs args, IDownloader webDownloader, IDownloader apiDownloader)
at SonarScanner.MSBuild.PreProcessor.PreProcessor.DoExecute(ProcessedArgs localSettings)
at SonarScanner.MSBuild.PreProcessor.PreProcessor.Execute(IEnumerable`1 args)
at SonarScanner.MSBuild.BootstrapperClass.PreProcess()
at SonarScanner.MSBuild.BootstrapperClass.Execute()
at SonarScanner.MSBuild.Program.Execute(String args, ILogger logger)
at SonarScanner.MSBuild.Program.Execute(String args)
at SonarScanner.MSBuild.Program.Main(String args)
at SonarScanner.MSBuild.Program.(String args)
Step 8 Run the sonarscanner: If I run the scanner without using the truststore.p12 with this Powershell command “dotnet sonarscanner begin /k:”" /d:sonar.host.url=<host_url> /d:sonar.token=“******************” /d:sonar.scanner.scanAll=false /d:sonar.verbose=true" I get the following result.
Result:
dotnet sonarscanner begin /k:“” /d:sonar.host.url=<host_url> /d:sonar.token=“**********************” /d:sonar.scanner.scanAll=false /d:sonar.verbose=true
SonarScanner for MSBuild 10.1.2
Using the .NET Core version of the Scanner for MSBuild
Default properties file was found at C:\Users\boblinn.dotnet\tools.store\dotnet-sonarscanner\10.1.2\dotnet-sonarscanner\10.1.2\tools\netcoreapp3.1\any\SonarQube.Analysis.xml
Loading analysis properties from C:\Users\boblinn.dotnet\tools.store\dotnet-sonarscanner\10.1.2\dotnet-sonarscanner\10.1.2\tools\netcoreapp3.1\any\SonarQube.Analysis.xml
sonar.verbose=true was specified - setting the log verbosity to ‘Debug’
Pre-processing started.
Preparing working directories…
Using environment variables to determine the download directory…
10:59:39.725 Loading analysis properties from C:\Users\boblinn.dotnet\tools.store\dotnet-sonarscanner\10.1.2\dotnet-sonarscanner\10.1.2\tools\netcoreapp3.1\any\SonarQube.Analysis.xml
10:59:39.748 Server Url: https://sonarqube.corp.sanmar.com
10:59:39.748 Api Url: https://sonarqube.corp.sanmar.com/api/v2
10:59:39.749 Is SonarCloud: False
10:59:39.757 No truststore provided; attempting to use the default location.
10:59:39.759 No truststore found at the default location; proceeding without a truststore.
10:59:39.767 sonar.verbose=true was specified - setting the log verbosity to ‘Debug’
10:59:39.773 Updating build integration targets…
10:59:39.778 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
10:59:39.779 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
10:59:39.78 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
10:59:39.78 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
10:59:39.78 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
10:59:39.781 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
10:59:39.781 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\boblinn\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
10:59:39.784 Installed SonarQube.Integration.targets to C:\Users\boblinn\source\repos\SEAM\src\SanMar.Azure.FunctionApps.Instrumentation.sonarqube\bin\targets
10:59:39.786 Creating config and output folders…
10:59:39.787 Creating directory: C:\Users\boblinn\source\repos\SEAM\src\SanMar.Azure.FunctionApps.Instrumentation.sonarqube\conf
10:59:39.788 Creating directory: C:\Users\boblinn\source\repos\SEAM\src\SanMar.Azure.FunctionApps.Instrumentation.sonarqube\out
10:59:39.816 Downloading from https://<host_url>/api/settings/values?component=unknown)…
10:59:39.968 Response received from <host_url>/api/settings/values?component=unknown…
10:59:39.972 Fetching server version…
10:59:39.981 Downloading from https://<host_url>/api/v2/analysis/version)…
10:59:39.997 Response received from https://<host_url>/api/v2/analysis/version)…
10:59:39.999 Downloading from https://<host_url>/api/v2/analysis/version) failed. Http status code is NotFound.
10:59:40.005 Downloading from https://<host_url>/api/server/version)…
10:59:40.01 Response received from https://<host_url>/api/server/version)…
10:59:40.012 Using SonarQube v9.9.8.100196.
10:59:40.013 Checking if the server version is supported…
10:59:40.016 Checking validity of server license…
10:59:40.017 Downloading from https://<host_url>/api/editions/is_valid_license)…
10:59:40.022 Response received from https://<host_url>/api/editions/is_valid_license)…
10:59:40.05 SonarQube Community Edition detected, license is valid.
10:59:40.053 JreResolver: Resolving JRE path.
10:59:40.054 JreResolver: Skipping Java runtime environment provisioning because this version of SonarQube does not support it.
10:59:40.059 Fetching analysis configuration settings…
10:59:40.065 Fetching properties for project ‘’…
10:59:40.067 Downloading from https://<host_url>/api/settings/values?component=)…
10:59:40.081 Response received from https://<host_url>/api/settings/values?component=)…
10:59:40.098 Downloading from https://<host_url>/api/languages/list)…
10:59:40.104 Response received from https://<host_url>/api/languages/list)…
10:59:40.109 Fetching quality profile for project ‘’…
10:59:40.111 Downloading from https://<host_url>/api/qualityprofiles/search?project=)…
10:59:40.131 Response received from https://<host_url>/api/qualityprofiles/search?project=)…
10:59:40.144 Fetching rules for quality profile ‘AXYfPHPSq4pddKGKBow4’…
10:59:40.145 Downloading from https://<host_url>/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AXYfPHPSq4pddKGKBow4&p=1)…
10:59:40.197 Response received from https://<host_url>/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AXYfPHPSq4pddKGKBow4&p=1)…
10:59:40.216 Local analyzer cache: C:\Users\boblinn\AppData\Local\Temp.sonarqube\resources
10:59:40.219 Writing Roslyn generated ruleset to C:\Users\boblinn\source\repos\SEAM\src\SanMar.Azure.FunctionApps.Instrumentation.sonarqube\conf\Sonar-cs.ruleset…
10:59:40.248 Writing Roslyn generated ruleset to C:\Users\boblinn\source\repos\SEAM\src\SanMar.Azure.FunctionApps.Instrumentation.sonarqube\conf\Sonar-cs-none.ruleset…
10:59:40.254 Provisioning analyzer assemblies for cs…
10:59:40.255 Installing required Roslyn analyzers…
10:59:40.255 Processing plugin: csharp version 8.51.0.59060
10:59:40.312 Cache hit: using plugin files from C:\Users\boblinn\AppData\Local\Temp.sonarqube\resources\0
10:59:40.32 Writing Roslyn analyzer additional file to C:\Users\boblinn\source\repos\SEAM\src\SanMar.Azure.FunctionApps.Instrumentation.sonarqube\conf\cs\SonarLint.xml…
10:59:40.322 Fetching quality profile for project ‘’…
10:59:40.322 Downloading from https://<host_url>/api/qualityprofiles/search?project=/api/qualityprofiles/search?project=…
10:59:40.349 Response received from https://<host_url>/api/qualityprofiles/search?project=)…
10:59:40.353 Fetching rules for quality profile ‘AXYfPH3Kq4pddKGKBpI8’…
10:59:40.354 Downloading from https://<host_url>/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AXYfPH3Kq4pddKGKBpI8&p=1)…
10:59:40.386 Response received from https://<host_url>/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AXYfPH3Kq4pddKGKBpI8&p=1)…
10:59:40.395 Local analyzer cache: C:\Users\boblinn\AppData\Local\Temp.sonarqube\resources
10:59:40.397 Writing Roslyn generated ruleset to C:\Users\boblinn\source\repos\SEAM\src\SanMar.Azure.FunctionApps.Instrumentation.sonarqube\conf\Sonar-vbnet.ruleset…
10:59:40.399 Writing Roslyn generated ruleset to C:\Users\boblinn\source\repos\SEAM\src\SanMar.Azure.FunctionApps.Instrumentation.sonarqube\conf\Sonar-vbnet-none.ruleset…
10:59:40.399 Provisioning analyzer assemblies for vbnet…
10:59:40.4 Installing required Roslyn analyzers…
10:59:40.4 Processing plugin: vbnet version 8.51.0.59060
10:59:40.4 Cache hit: using plugin files from C:\Users\boblinn\AppData\Local\Temp.sonarqube\resources\1
10:59:40.401 Writing Roslyn analyzer additional file to C:\Users\boblinn\source\repos\SEAM\src\SanMar.Azure.FunctionApps.Instrumentation.sonarqube\conf\vbnet\SonarLint.xml…
10:59:40.409 Processing analysis cache
10:59:40.415 Incremental PR analysis: Base branch parameter was not provided.
10:59:40.415 Cache data is empty. A full analysis will be performed.
10:59:40.447 Pre-processing succeeded.
Step 9. Run the build: “dotnet build” (using the previous successful scanner)
Result: Build succeeded with 91 warning(s) in 23.5s
Step 10. End the scanner: dotnet sonarscanner end /d:sonar.token=“*******************”
SonarScanner for MSBuild 10.1.2
Using the .NET Core version of the Scanner for MSBuild
Post-processing started.
(list displays the files and issues… ending with)