# HTTPS Proxy Authentication Broken in Scanner CLI 8.0 / Java Library 4.0 (HTTP 407 Error)

**URL:** <https://community.sonarsource.com/t/https-proxy-authentication-broken-in-scanner-cli-8-0-java-library-4-0-http-407-error/172516>\
**Category:** Rules and Languages\
**Created:** [January 9, 2026, 1:39am UTC](https://community.sonarsource.com/t/https-proxy-authentication-broken-in-scanner-cli-8-0-java-library-4-0-http-407-error/172516 "2026-01-09T01:39:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kychen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/kychen/32/74423_2.png) [@kychen](https://community.sonarsource.com/u/kychen)\
**Post date:** [January 9, 2026, 1:39am UTC](https://community.sonarsource.com/t/https-proxy-authentication-broken-in-scanner-cli-8-0-java-library-4-0-http-407-error/172516/1 "2026-01-09T01:39:22Z")

</div>

HTTPS proxy authentication is broken in **SonarScanner CLI 8.0.0.6341** (using sonar-scanner-java-library 4.0.0). The scanner fails with `HTTP 407 Proxy Authentication Required` when connecting to an HTTPS SonarQube server through an authenticated HTTP proxy.

**This is a regression** - proxy authentication works correctly in Scanner CLI 7.0.2 (java-library 3.x).

## **Environment**

- **SonarScanner CLI Version** : 8.0.0.6341

- **Java Library Version** : 4.0.0. 1577

- **SonarQube Server URL** : HTTPS (e.g., `https://xxxxx`)

- **Proxy Configuration** :

Scanner debug log：

```auto
09:51:10.283 DEBUG --> GET https://xxx/api/v2/analysis/version
09:51:10.410 DEBUG Received 407 Proxy Authentication Required, retrying with Proxy-Authorization header
09:51:10.411 DEBUG --> GET https://xxx/api/v2/analysis/version
09:51:10.419 DEBUG <-- 407 https://xxx/api/v2/analysis/version (7ms)
09:51:10.419 DEBUG <-- 407 https://xxx/api/v2/analysis/version (135ms)

ERROR Failed to query server version: GET https://xxx/api/v2/analysis/version 
failed with HTTP 407 Proxy Authentication Required

```

The retry attempt shows that `Proxy-Authorization` header is being added, but the proxy still returns 407, indicating that the authentication is not being properly sent in the **HTTPS CONNECT tunnel**.

After investigating the source code, I found the root cause:

\*\*PR #268（**[https://github.com/SonarSource/sonar-scanner-java-library/pull/268\*\*）](https://github.com/SonarSource/sonar-scanner-java-library/pull/268**%EF%BC%89)**(commit `146b94cde9201c8be04c98475ff2c9e637c7704e`) replaced**OkHttp with JDK’s native HttpClient **. However, this migration** missed a critical component**: the `Authenticator` configuration needed for HTTPS proxy authentication.

---

<div class="post-metadata">

**Author:** ![Julien\_HENRY](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/julien_henry/32/61_2.png) [@Julien\_HENRY](https://community.sonarsource.com/u/Julien_HENRY)\
**Post date:** [March 9, 2026, 8:21am UTC](https://community.sonarsource.com/t/https-proxy-authentication-broken-in-scanner-cli-8-0-java-library-4-0-http-407-error/172516/9 "2026-03-09T08:21:56Z")

</div>

Hi @kychen

Thanks you very much for the detailed report.

We are indeed willing to move away from okhttp and use the native Java httpclient. The problem is there is a bug in JDK \< 24, where you can’t have both a proxy Authenticator and some preemptive authentication header (_JDK-8326949)._

I will try to find a workaround, you can follow this ticket: [Jira](https://sonarsource.atlassian.net/browse/SCANJLIB-306)

---

<div class="post-metadata">

**Author:** ![Julien\_HENRY](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/julien_henry/32/61_2.png) [@Julien\_HENRY](https://community.sonarsource.com/u/Julien_HENRY)\
**Post date:** [March 9, 2026, 10:12am UTC](https://community.sonarsource.com/t/https-proxy-authentication-broken-in-scanner-cli-8-0-java-library-4-0-http-407-error/172516/10 "2026-03-09T10:12:54Z")

</div>

@kychen are you using the Scanner CLI with its embedded JRE (Java 21), or are you using an older Java version?

---

<div class="post-metadata">

**Author:** ![kychen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/kychen/32/74423_2.png) [@kychen](https://community.sonarsource.com/u/kychen)\
**Post date:** [May 8, 2026, 11:38am UTC](https://community.sonarsource.com/t/https-proxy-authentication-broken-in-scanner-cli-8-0-java-library-4-0-http-407-error/172516/13 "2026-05-08T11:38:55Z")

</div>

java 21, I see that you’ve fixed this in the latest version, and I will be conducting regression testing soon. Thank you for your response.

---

<div class="post-metadata">

**Author:** ![Julien\_HENRY](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/julien_henry/32/61_2.png) [@Julien\_HENRY](https://community.sonarsource.com/u/Julien_HENRY)\
**Post date:** [May 11, 2026, 6:55am UTC](https://community.sonarsource.com/t/https-proxy-authentication-broken-in-scanner-cli-8-0-java-library-4-0-http-407-error/172516/14 "2026-05-11T06:55:02Z")

</div>

Hi,

Indeed we released a version with a fix, but that was only tested using a mocked proxy, so I would be happy to hear how this is working in a real life scenario.

Thanks
