Sonar Scanner cannot talk to Server due to PKIX path building failed

Specs:
SonarQube Version: 9.9
SonarScanner for MSBuild 5.11
Deployment mechanism: Zip
Language: C# (.NET Core 6)
OS hosting SonarQube: Ubuntu 20.04
OS running Scan: Windows 10

We have SonarQube version 9.9 instance installed on Ubuntu 20.04. Server is funning fine and configured correctly. However, once we started scanning, the scanner cannot talk to the server to post the scan findings. I received the below error:

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Scan & Build Commands:

dotnet sonarscanner begin /k:"Project.Sandbox" /d:sonar.login="sqa_REDACTED" /d:sonar.verbose=true /d:sonar.branch.name="main" /d:sonar.host.url=https://sonar.some-domain-name.com 
 
dotnet build .\Building.Data.sln /p:PackageVersion=$SemanticVersion /t:Publish /p:version=$SemanticVersion /p:restore=True -c "Release" -v normal --force
 
dotnet sonarscanner end /d:sonar.login="sqa_REDACTED"

RESULT:
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Recommended Solution I tried:
keytool -import -alias SonarCert -keystore "C:\Program Files\Java\jdk-11\lib\security\cacerts" -file C:\PROJECTS\Certificates\sonar-server-cert.crt

Even after adding the cert to the keystore, I still get the same error. I tried on different machine and did the same thing and always get the same error.

What am I missing or doing wrong?

Thanks everyone!

Hi,

Welcome to the community!

There are lots of threads here about this error, and you may find specific pointers in them. In general I can tell you that this is a certificate error. You need to get the cert into the Java keystore on the build agent.

 
HTH,
Ann

Thanks for the reply! I did look into several of those threads, and that’s where I found the recommended solution. However, even with the recommended workaround, I am still getting the same error.