Skip to content

Add HTTP proxy and corporate-CA support for SDK and bundled CLI - #2178

Open
misha-db wants to merge 14 commits into
mainfrom
http-proxy
Open

Add HTTP proxy and corporate-CA support for SDK and bundled CLI#2178
misha-db wants to merge 14 commits into
mainfrom
http-proxy

Conversation

@misha-db

@misha-db misha-db commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Changes

What

Makes the extension work behind corporate HTTP/HTTPS proxies and against
workspaces whose TLS certificate is signed by an internal CA — for both the
in-process Databricks JS SDK and the bundled Go CLI.

Why

Users on corp-managed machines (proxy-only networks, TLS-intercepting proxies,
internal CAs) currently hit two problems:

  1. Proxy not applied. The SDK never routed through a proxy, and the CLI only
    picked one up from OS env vars — never from the VS Code http.proxy setting.
  2. Corp CA not trusted. The SDK pins its own HTTP agent (bypassing VS Code's
    global TLS patching), so an OS-trusted internal CA was ignored and SDK calls
    failed with SELF_SIGNED_CERT_IN_CHAIN / UNABLE_TO_GET_ISSUER_CERT_LOCALLY.
    The bundled Go CLI was unaffected (it reads the OS store natively).

What changed

Proxy resolution (SDK + CLI)

  • New src/utils/network/proxyAgent.ts builds a proxy- and CA-aware agent via
    @vscode/proxy-agent, resolving the proxy the way VS Code core does:
    http.proxy setting first, then http(s)_proxy env vars, honoring
    http.noProxy / NO_PROXY. createWorkspaceClient is now the single place
    the extension constructs a WorkspaceClient; the auth checks (AuthProvider,
    AzureCliCheck, DatabricksCliCheck) route through it.
  • getProxyEnvVars (forwarded to the CLI subprocess) now also reads the VS Code
    http.proxy / http.noProxy settings, not just OS env vars — the Go CLI
    honors a proxy only through these env vars, so this keeps the CLI and SDK
    resolving the same proxy from the same inputs.

Certificate trust (SDK)

  • The agent's ca is built by merging Node's bundled roots
    (tls.rootCertificates) + the OS trust store + an optional user PEM, deduped.
    Previously the OS store replaced the bundled roots, which could break
    public-root TLS.
  • CA loading is version-aware: on Node ≥ 22.15 it uses tls.getCACertificates;
    on older runtimes (shipped by many supported VS Code builds) it falls back to
    @vscode/proxy-agent's native readers, which is why the win32 VSIXs now ship
    the native @vscode/windows-ca-certs module (win32-only optional dependency,
    copied into out/ at package time).
  • New databricks.proxy.caCert setting — an absolute path to a PEM bundle — as
    a cross-platform escape hatch, merged onto the trust store.

Strict SSL

  • New databricks.proxy.strictSSL setting overrides the built-in
    http.proxyStrictSSL (both default to verification on). Activation and the SDK
    client path now resolve strict-SSL through the same layered setting, so the
    DATABRICKS_SDK_PROXY_STRICT_SSL env var (read by the SDK fetch path) is
    consistent and defaults to on when nothing is configured.

Graceful degradation

Every failure path is recoverable: an unreadable OS store or missing native
module falls back to Node's bundled roots, an unreadable caCert path is logged
and ignored, and none of these break the agent. TLS verification stays on by
default throughout.

Tests

  • Unit tests for proxy resolution, CA merge/dedup, caCert (success + fallback +
    unreadable path), the version-aware flag, and strict-SSL env wiring.
  • yarn workspace databricks run test:unit — all green (1078 passing).

Not covered by CI: the old-Node Windows corp-CA path requires the native
module to actually be present, which depends on the win32 VSIX being built on a
Windows host. Verify the release pipeline before relying on it; the
databricks.proxy.caCert setting is the fallback if it isn't shipped.

workspace TLS cert chains to an OS-trusted internal CA. Two causes:

- proxyAgent hardcoded loadSystemCertificatesFromNode: true, so
  @vscode/proxy-agent called tls.getCACertificates (Node >= 22.15 only).
  On older Node (shipped by many supported VS Code builds) it threw, the
  OS store was lost, and the agent fell back to Node's bundled roots —
  which don't include the corp CA.
- On the success path the agent set `ca` to only the OS store, which
  *replaces* Node's bundled public roots (getCACertificates('system')
  returns far fewer certs than tls.rootCertificates), a latent bug that
  could break public-root TLS.

Fixes:
- Make loadSystemCertificatesFromNode version-aware so older runtimes use
  proxy-agent's native readers (@vscode/windows-ca-certs on Windows,
  security on macOS, PEM files on Linux).
- Always merge tls.rootCertificates + OS store + configured PEM; omit
  `ca` entirely only when nothing extra is loaded.
- Add databricks.proxy.caCert setting as a cross-platform escape hatch.
- Ship @vscode/windows-ca-certs in the win32 VSIXs (win32-only optional
  dep, copied into out/node_modules via package-vsix.sh gating).

A missing/failed native module degrades to bundled roots + caCert, never
a hard failure. TLS verification stays on by default throughout.
- buildCaBundle: dedupe with a Set (the OS store commonly re-lists the
  public roots already in tls.rootCertificates) and tighten the return
  type to string[] (it never produced Buffers).
- getProxyEnvVars: document that http.proxy overrides the env var while
  no_proxy is unioned with it, not overridden.
- Add a test asserting the CA bundle contains no duplicates.
@misha-db
misha-db deployed to test-trigger-is September 7, 2026 11:17 — with GitHub Actions Active
@misha-db
misha-db deployed to test-trigger-is September 7, 2026 11:18 — with GitHub Actions Active
@misha-db
misha-db deployed to test-trigger-is September 7, 2026 11:18 — with GitHub Actions Active
@rugpanov

rugpanov commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

🤖 Integration tests ❌ failed for 25219fd6.
View run

Preserve the Databricks SDK request timeout when injecting the extension's
  proxy-aware HTTP agent, including the SDK's default 5s timeout.

  Also merge VS Code http.noProxy with NO_PROXY/no_proxy for SDK proxy
  resolution so SDK calls and CLI subprocesses honor the same bypass list.
@misha-db
misha-db deployed to test-trigger-is September 7, 2026 12:12 — with GitHub Actions Active
@misha-db
misha-db deployed to test-trigger-is September 7, 2026 12:14 — with GitHub Actions Active
@misha-db
misha-db deployed to test-trigger-is September 7, 2026 12:14 — with GitHub Actions Active
@rugpanov

rugpanov commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

🤖 Integration tests ❌ failed for a6630e11.
View run

@misha-db
misha-db deployed to test-trigger-is September 9, 2026 09:16 — with GitHub Actions Active
@misha-db
misha-db deployed to test-trigger-is September 9, 2026 09:16 — with GitHub Actions Active
@misha-db
misha-db deployed to test-trigger-is September 9, 2026 09:17 — with GitHub Actions Active
@rugpanov

rugpanov commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Integration tests running for 0727387b — ⏳.
View run

@misha-db
misha-db deployed to test-trigger-is September 9, 2026 09:32 — with GitHub Actions Active
@misha-db
misha-db deployed to test-trigger-is September 9, 2026 09:33 — with GitHub Actions Active
@misha-db
misha-db deployed to test-trigger-is September 9, 2026 09:33 — with GitHub Actions Active
@rugpanov

rugpanov commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Integration tests ❌ failed for 705b4f01.
View run

@misha-db
misha-db deployed to test-trigger-is September 9, 2026 11:12 — with GitHub Actions Active
@misha-db
misha-db deployed to test-trigger-is September 9, 2026 11:12 — with GitHub Actions Active
@misha-db
misha-db deployed to test-trigger-is September 9, 2026 11:13 — with GitHub Actions Active
@rugpanov

rugpanov commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Integration tests ❌ failed for 80470b33.
View run

@misha-db
misha-db deployed to test-trigger-is September 9, 2026 13:48 — with GitHub Actions Active
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/vscode

Inputs:

  • PR number: 2178
  • Commit SHA: 578761451d032ef853d81ef79ba9c61b15f57e6f

Checks will be approved automatically on success.

@misha-db
misha-db deployed to test-trigger-is September 9, 2026 13:49 — with GitHub Actions Active
@misha-db
misha-db deployed to test-trigger-is September 9, 2026 13:49 — with GitHub Actions Active
@rugpanov

rugpanov commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Integration tests ❌ failed for 57876145.
View run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants