Invalid credentials when connecting to SonarQube

I seem to have the same circumstances (VSCode Connected Mode with correct settings).

I still have this issue after doing the following steps:

  • Retrieved extension’s JAVA Home path
  • Downloaded all certs (3) from Firefox when browsing my company’s sonarqube portal.
  • Added 3 certs to extension’s JRE with following command (obfuscated private information with variables)
    $SONARLINT_JAVA_HOME/bin/keytool.exe -importcert -alias $CERT1_ALIAS -storepass changeit -keystore $SONARLINT_JAVA_HOME/lib/security/cacerts -file ~/Downloads/$CERT1_FILE
  • VSCode: Update all project bindings to SonarQube/SonarCloud

Logs (username and company name obfuscated)

[Debug - 10:51:17.742] Starting connected SonarLint engine for 'mycompany'...
[Debug - 10:51:17.749] Looking for node in the PATH
[Debug - 10:51:17.753] Execute command 'C:\Windows\System32\where.exe $PATH:node.exe'...
[Debug - 10:51:17.968] Command 'C:\Windows\System32\where.exe $PATH:node.exe' exited with 0
stdout: C:\Program Files\nodejs\node.exe
[Debug - 10:51:17.968] Found node at C:\Program Files\nodejs\node.exe
[Debug - 10:51:17.968] Checking node version...
[Debug - 10:51:17.968] Execute command 'C:\Program Files\nodejs\node.exe -v'...
[Debug - 10:51:18.031] Command 'C:\Program Files\nodejs\node.exe -v' exited with 0
stdout: v14.17.5
[Debug - 10:51:18.031] Detected node version: 14.17.5
[Debug - 10:51:18.198] Create : C:\Users\myuser\.sonarlint\plugins
[Debug - 10:51:18.199] Plugin cache: C:\Users\myuser\.sonarlint\plugins
[Debug - 10:51:18.199] Create : C:\Users\myuser\.sonarlint\plugins\_tmp
[Debug - 10:51:18.203] Load plugins
[Debug - 10:51:18.204] Load plugins (done) | time=0ms
[Debug - 10:51:18.219] No plugins loaded
[Warn  - 10:51:18.219] No storage for connection 'mycompany'. Please update.
[Info  - 10:51:18.219] Creating container for module with key=file:///c:/applis/myproject
[Debug - 10:51:18.239] SonarLint engine started for connection 'mycompany'
[Debug - 10:51:18.294] Create : C:\Users\myuser\.sonarlint\plugins
[Debug - 10:51:18.295] Plugin cache: C:\Users\myuser\.sonarlint\plugins
[Debug - 10:51:18.295] Create : C:\Users\myuser\.sonarlint\plugins\_tmp
[Debug - 10:51:18.319] GET 401 https://core-sonarqube.apps.mycompany.int/api/plugins/installed | response time=0ms
[Debug - 10:51:18.346] Create : C:\Users\myuser\.sonarlint\plugins
[Debug - 10:51:18.346] Plugin cache: C:\Users\myuser\.sonarlint\plugins
[Debug - 10:51:18.346] Create : C:\Users\myuser\.sonarlint\plugins\_tmp
[Debug - 10:51:18.347] Load plugins
[Debug - 10:51:18.348] Load plugins (done) | time=1ms
[Debug - 10:51:18.350] No plugins loaded
[Warn  - 10:51:18.350] No storage for connection 'mycompany'. Please update.
[Info  - 10:51:18.352] Creating container for module with key=file:///c:/applis/myproject
[Error - 10:51:18.358] Error updating the local storage of the connection with id 'mycompany'
[Error - 10:51:18.360] java.lang.IllegalStateException: Not authorized. Please check server credentials.
at org.sonarsource.sonarlint.core.serverapi.ServerApiHelper.handleError(ServerApiHelper.java:125)
at org.sonarsource.sonarlint.core.serverapi.ServerApiHelper.get(ServerApiHelper.java:72)
at org.sonarsource.sonarlint.core.container.connected.update.PluginListDownloader.lambda$downloadPluginList$0(PluginListDownloader.java:58)
at org.sonarsource.sonarlint.core.serverapi.ServerApiHelper.processTimed(ServerApiHelper.java:220)
at org.sonarsource.sonarlint.core.container.connected.update.PluginListDownloader.downloadPluginList(PluginListDownloader.java:57)
at org.sonarsource.sonarlint.core.container.connected.update.perform.GlobalStorageUpdateExecutor.update(GlobalStorageUpdateExecutor.java:93)
at org.sonarsource.sonarlint.core.container.connected.ConnectedContainer.update(ConnectedContainer.java:133)
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.lambda$update$2(ConnectedSonarLintEngineImpl.java:182)
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.runInConnectedContainer(ConnectedSonarLintEngineImpl.java:331)
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.lambda$update$3(ConnectedSonarLintEngineImpl.java:182)
at org.sonarsource.sonarlint.core.AbstractSonarLintEngine.withRwLock(AbstractSonarLintEngine.java:109)
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.update(ConnectedSonarLintEngineImpl.java:177)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.updateGlobalStorageAndLogResults(ProjectBindingManager.java:509)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$tryUpdateConnectionAndBoundProjectsStorages$19(ProjectBindingManager.java:458)
at org.sonarsource.sonarlint.ls.progress.SubProgressMonitor.doInSubProgress(SubProgressMonitor.java:59)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$tryUpdateConnectionAndBoundProjectsStorages$21(ProjectBindingManager.java:458)
at org.sonarsource.sonarlint.ls.progress.LSProgressMonitor.doInSubProgress(LSProgressMonitor.java:151)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.tryUpdateConnectionAndBoundProjectsStorages(ProjectBindingManager.java:447)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$tryUpdateConnectionsAndBoundProjectStorages$18(ProjectBindingManager.java:441)
at java.base/java.util.HashMap.forEach(Unknown Source)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.tryUpdateConnectionsAndBoundProjectStorages(ProjectBindingManager.java:440)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.updateBindings(ProjectBindingManager.java:415)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$updateAllBindings$14(ProjectBindingManager.java:401)
at org.sonarsource.sonarlint.ls.progress.ProgressManager.doWithProgress(ProgressManager.java:74)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.updateAllBindings(ProjectBindingManager.java:397)
at org.sonarsource.sonarlint.ls.CommandManager.executeCommand(CommandManager.java:248)
at org.sonarsource.sonarlint.ls.SonarLintLanguageServer.lambda$executeCommand$5(SonarLintLanguageServer.java:315)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

[Error - 10:51:18.361] Binding update failed for project key 'myproject:master'
[Error - 10:51:18.362] org.sonarsource.sonarlint.core.client.api.exceptions.GlobalStorageUpdateRequiredException: Storage of server 'mycompany' requires an update
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.checkUpdateStatus(ConnectedSonarLintEngineImpl.java:239)
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.updateProject(ConnectedSonarLintEngineImpl.java:281)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$tryUpdateBoundProjectsStorage$22(ProjectBindingManager.java:469)
at org.sonarsource.sonarlint.ls.progress.SubProgressMonitor.doInSubProgress(SubProgressMonitor.java:59)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$tryUpdateBoundProjectsStorage$23(ProjectBindingManager.java:467)
at java.base/java.lang.Iterable.forEach(Unknown Source)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.tryUpdateBoundProjectsStorage(ProjectBindingManager.java:467)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$tryUpdateConnectionAndBoundProjectsStorages$20(ProjectBindingManager.java:460)
at org.sonarsource.sonarlint.ls.progress.SubProgressMonitor.doInSubProgress(SubProgressMonitor.java:59)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$tryUpdateConnectionAndBoundProjectsStorages$21(ProjectBindingManager.java:460)
at org.sonarsource.sonarlint.ls.progress.LSProgressMonitor.doInSubProgress(LSProgressMonitor.java:151)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.tryUpdateConnectionAndBoundProjectsStorages(ProjectBindingManager.java:447)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$tryUpdateConnectionsAndBoundProjectStorages$18(ProjectBindingManager.java:441)
at java.base/java.util.HashMap.forEach(Unknown Source)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.tryUpdateConnectionsAndBoundProjectStorages(ProjectBindingManager.java:440)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.updateBindings(ProjectBindingManager.java:415)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$updateAllBindings$14(ProjectBindingManager.java:401)
at org.sonarsource.sonarlint.ls.progress.ProgressManager.doWithProgress(ProgressManager.java:74)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.updateAllBindings(ProjectBindingManager.java:397)
at org.sonarsource.sonarlint.ls.CommandManager.executeCommand(CommandManager.java:248)
at org.sonarsource.sonarlint.ls.SonarLintLanguageServer.lambda$executeCommand$5(SonarLintLanguageServer.java:315)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

Hello @honmaj,

Sorry for the late response. I decided to move your message to a dedicated topic as it seems unrelated. In the future please avoid bumping old threads.

SonarLint issues a request to the server and gets a 401 Unauthorized response. There could be different causes to this error, not only a certificate issue.

Could you show us how you configured your SonarQube connection ? I’m interested in what you have in your user settings file.
Is there a proxy between you and your SonarQube instance ?
Is it possible that your SonarQube server expects a client certificate ?