We have a need to spawn fresh VM’s to run sonarscanner via GitLab CI. We’re almost there. Our last challenge is getting a private-CA-generated certificate to work. There’s a handful of solutions I can think of, but I’m not sure what the correct solution is.
Primary question
- How does “JreResolver” work? If I can pre-install java, that will solve everything, cause then I can pre-update the keystore. I’ve got both PATH and JAVA_HOME set correctly, and that seems to have no effect.
Details
I believe the issue is due to sonarscanner failing to find the java installed on the template machine, and so it downloads a fresh JRE from our SonarQube server, which of course doesn’t have the keystore updated in whatever JRE it downloaded. If the machine was persistent, I’d run the sonarscanner once, let it fail, then manually update the java keystore that’s deep in the ~/.sonar/cache/ area. Seems like a messy solution though.
Here’s the original error
> dotnet-sonarscanner end /d:sonar.token=$SONARQUBE_TOKEN
...
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Here’s whats leading to that error
23:25:13.093 JreResolver: Resolving JRE path.
23:25:13.096 Downloading from https://<PRIVATE_DNS>.com/api/v2/analysis/jres?os=linux&arch=x64...
23:25:13.104 Response received from https://<PRIVATE_DNS>.com/api/v2/analysis/jres?os=linux&arch=x64...
23:25:13.25 JreResolver: Cache miss. Attempting to download JRE.
23:25:13.26 Starting the Java Runtime Environment download.
# THE FRESHLY DOWNLOADED JRE OBVIOUSLY WONT HAVE PRIVATE CERT INSTALLED
Bonus note: I see on our SonarQube server, there’s a directory “sonarqube\jres” with a bunch of zip/gz files. I’m guessing one of those are downloaded. So I’m kinda guessing I could unzip all those, update the keystores, and re-zip them if I wanted to. However, this doesn’t get what we REALLY want, which is a fresh VM where everything is already downloaded and ready to go. Since this is for CI, we really want everything as fast as possible.
I’ve already installed openjdk-17-jre on the template VM, and ensured PATH and JAVA_HOME both have the correct path to java, and that seems to do nothing.