Python repo: unable to find valid certification path to requested target

I try to run de sonar-scanner.bat analyzer over my python repository, but the sonar server is private
I got this error:
Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I tried to run this command in Windows.

Also, I can configure the same analyzer but for another project, in this case, a JAVA project. I add the cert.pem file into the Java keystore, but… How can I also add the cert.pem file for this project in python?

Thanks in advance

Hi,

Welcome to the community!

You’ve correctly diagnosed this as a problem with the certificate, but there’s nothing to import into Python. You need to get it fully imported into your Java trust store. The docs may help.

 
Ann

hello Ann. Thanks for your answer

For my test in the repository with Java, I have added the certificate to the java keystore in windows: “C:\Program Files\Java\jdk-18.0.2.1\lib\security\cacerts”

Also, since I work with several versions I have also added it to: “C:\Program Files (x86)\Java\jre-1.8\lib\security\cacerts”.
and also to “C:\Program Files\Java\jdk-18.0.2.1\lib\security\cacerts”

Do you think I’m missing something, because I don’t have any other java versions installed on my machine that I know of.

Greetings and thanks again

Hi,

Is this a self-signed certificate? Did you read the docs I pointed you to? If it’s self-signed, you’ll need to import the full chain.

 
HTH,
Ann

I followed the “For SonarScanner for Maven, Gradle, or CLI” section.
And added the trustStore and Password options

sonar-scanner.bat -D"sonar.projectKey=python-fon-lib" -D"sonar.sources=." -D"sonar.host.url=—" -D"sonar.token=–" -D"javax.net.ssl.trustStore=\repositories\tls-mutual-nginx\cacerts" -D"javax.net.ssl.trustStorePassword=changeit"

I need to do something more? I’m sorry if I’m not seeing clearly

Hi,

Take a closer look at that documentation I pointed you to. It’s not a parameter on the analysis command line.

 
Ann

Okey, I set the environment variable, but doesn’t work
[System.Environment]::SetEnvironmentVariable(“SONAR_SCANNER_OPTS”, “-Djavax.net.ssl.trustStore=\repositories\tls-mutual-nginx\cacerts -Djavax.net.ssl.trustStorePassword=changeit”) ← In windows PS

sonar-scanner.bat -D"sonar.projectKey=python-fon-lib" -D"sonar.sources=." -D"sonar.host.url=[host]" -D"sonar.token=[token]"

Hi,

Sorry, but I have nothing to offer here beyond those docs.

 
Ann

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.