We are trying to use the SonarScanner CLI to run locally against fetched repos but are getting the following error:
Unable to fetch API V2 /analysis/version: Error: unable to verify the first certificate. Falling back on /api/server/version
We have imported our certificate into the cacerts store within the \sonar-scanner-7.2.0.5079-windows-x64\jre\lib\security path and validated it is in the cacert store
When executing a command to analyze we receive the following:
[INFO] Bootstrapper: Platform: win32 x64 [DEBUG] Bootstrapper: Detecting proxy: No proxy detected [INFO] Bootstrapper: Server URL: ``https://oursonar [INFO] Bootstrapper: Version: 4.3.0 [DEBUG] Bootstrapper: Check if Server supports JRE provisioning [DEBUG] Bootstrapper: Detecting SonarQube server version [DEBUG] Bootstrapper: Fetching API V2 /analysis/version [DEBUG] Bootstrapper: Unable to fetch API V2 /analysis/version: Error: unable to verify the first certificate. Falling back on /api/server/version [DEBUG] Bootstrapper: Not using axios instance for ``https://oursonar/api/server/version [ERROR] Bootstrapper: Failed to fetch server version: Error: unable to verify the first certificate [ERROR] Bootstrapper: Verify that ``https://oursonar`` is a valid SonarQube server [ERROR] Bootstrapper: An error occurred: Error: unable to verify the first certificate
Any ideas on next steps? Do we need an environmental variable as well since the repos we are analyzing are cloned from Azure DevOps?
Yes, multiple times and use the commands SonarQube gives me to call for the repo. I have updated the properties file and tried environmental variables. Still fails. I even tried a full call with a path to my keystore. Example:
The truststore must be in .p12 (PKCS#12) format, not .jks. Also, the correct property to override the truststore path is sonar.scanner.truststorePath, not sonar.sonar.scanner.truststorePath.
Thank you Colin, we had also tried the .p12 and had the same error. I have the path as Dsonar.sonar.scanner to match -Dsonar.host, etc. I will remove the Dsonar and test.
Thank you Colin. I will give this a go. Any ideas why setting the truststorepath and password in the sonar-scanner.properties file doesn’t work… or does that need to go into a project specific properties file?
This indicates it is using the storepath but still fails:
[INFO] Bootstrapper: Platform: win32 x64 [DEBUG] Bootstrapper: Detecting proxy: No proxy detected [DEBUG] Bootstrapper: Using truststore at C:\mypath\sonar-scanner-cli-7.2.0.5079-windows-x64\sonar-scanner-7.2.0.5079-windows-x64\jre\bin\mysonar.p12 [DEBUG] Bootstrapper: 1 CA certificates found in truststore [INFO] Bootstrapper: Server URL: ``https://mysonar.local [INFO] Bootstrapper: Version: 4.3.0 [DEBUG] Bootstrapper: Check if Server supports JRE provisioning [DEBUG] Bootstrapper: Detecting SonarQube server version [DEBUG] Bootstrapper: Fetching API V2 /analysis/version [DEBUG] Bootstrapper: Unable to fetch API V2 /analysis/version: Error: unable to verify the first certificate. Falling back on /api/server/version [DEBUG] Bootstrapper: Not using axios instance for ``https://mysonar.local/api/server/version [ERROR] Bootstrapper: Failed to fetch server version: Error: unable to verify the first certificate [ERROR] Bootstrapper: Verify that ``https://mysonar.local`` is a valid SonarQube server [ERROR] Bootstrapper: An error occurred: Error: unable to verify the first certificate
Any other ideas @Colin? Of note, I don’t see a “default location for the TrustStore is $SONAR_USER_HOME/ssl/truststore.p12 (default value for SONAR_USER_HOME is ~/.sonar)” in the SonarScanner I downloaded from the SonarQube site. Where is the /ssl/truststore?
I am having a heck of a time reproducing this myself, and I do wonder if it’s the result of something “in the middle” (ZScaler is a common culprit). I’ll come back to this tomorrow on my own network and see if that changes anything.
Thank you Colin, for all the help on this one. We will test and post the updates. We were wondering the same thing per our VPN as our SonarQube is internally facing.
By the way, I saw this morning we have a bug where the SonarScanner for NPM isn’t picking up the deafult truststore location. So keep on specifying -Dsonar.scanner.truststorePath.
Update, I am running SonarScanner from a jump box (no VPN as my local machine is behind a VPN) and getting much further. Will report back if I can get it to run completely.