Repository navigation
agentHost: Forward client certificates to WSL and local containers - #343431
Merged
Christof Marti (chrmarti) merged 12 commits intoOct 28, 2026
Merged
Conversation
Pass client trust roots to WSL and desktop-local Dev Containers through a negotiated Agent Host API, keeping native AH trust in memory and PEM bundles scoped to Copilot. Merge existing user bundles and guard certificate setup across reconnects. Related to #342540. Kerberos proxy authentication is unchanged. Co-authored-by: Copilot <[email protected]>
Refresh the new proxy-aware WebSocket cache when client trust changes, wire the certificate resolver into new host tests, and use the upstream proxy-refresh promise instead of timer polling. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
1 open issue
What changed in this PR
Adds support for forwarding client machine CA certificates to local-network Agent Host scenarios (WSL + desktop-local Dev Containers), using a capability-negotiated vscode/setClientCertificates protocol method, while ensuring the Agent Host process environment is not modified and only the Copilot runtime receives NODE_EXTRA_CA_CERTS.
Changes:
- Introduces a client-certificates capability + protocol method, with server-side validation, storage, and log redaction.
- Wires certificate forwarding into WSL, Editor remote agent host client, and Dev Container connection flows (local only +
http.systemCertificatesgated). - Adds a shared, atomic, content-addressed PEM bundling utility and test coverage for trust/bundle behavior.
| File | Description |
|---|---|
| src/vs/workbench/services/agentHost/test/browser/editorRemoteAgentHostServiceClient.test.ts | Adds browser-side tests for when/where certificate forwarding is enabled. |
| src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts | Adds certificate resolution logic for local-network remotes prior to auth. |
| src/vs/sessions/contrib/providers/remoteAgentHost/test/electron-browser/devContainerAgentHostConnector.test.ts | Extends Dev Container connector tests to cover client certificate resolution. |
| src/vs/sessions/contrib/providers/remoteAgentHost/electron-browser/devContainerAgentHostConnector.contribution.ts | Exposes resolveClientCertificates for local (non-remoteService) Dev Container connections. |
| src/vs/sessions/contrib/providers/remoteAgentHost/browser/devContainerAgentHostService.ts | Plumbs resolveClientCertificates into the protocol client options for Dev Containers. |
| src/vs/sessions/common/devContainerAgentHostService.ts | Extends connection contract to optionally provide client certificate resolution. |
| src/vs/platform/request/test/node/certificates.test.ts | Adds tests for content-addressed bundle writing + NODE_EXTRA_CA_CERTS merging behavior. |
| src/vs/platform/request/node/certificates.ts | Introduces atomic, owned-only certificate bundle writing + env var configuration helper. |
| src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts | Adds server tests for certificate API behavior, validation, and relay restrictions. |
| src/vs/platform/agentHost/test/node/localModelBridge/shimLocalModelProvider.test.ts | Updates proxy resolver test stubs for new certificate methods/fields. |
| src/vs/platform/agentHost/test/node/localModelBridge/localModelSetupService.test.ts | Updates proxy resolver test stubs for new certificate methods/fields. |
| src/vs/platform/agentHost/test/node/devContainerAgentHostService.test.ts | Adds tests for Dev Container locality-based forwarding eligibility. |
| src/vs/platform/agentHost/test/node/copilotAgent.test.ts | Adds coverage for Copilot runtime-only NODE_EXTRA_CA_CERTS application and refresh. |
| src/vs/platform/agentHost/test/node/agentServiceTestUtils.ts | Updates proxy resolver test utility to satisfy new interface. |
| src/vs/platform/agentHost/test/node/agentHostTcp.test.ts | Wires proxy resolver into handler construction to match new dependency list. |
| src/vs/platform/agentHost/test/node/agentHostRequestService.test.ts | Adds tests verifying client certs are retained in-memory and combined for AH requests. |
| src/vs/platform/agentHost/test/electron-browser/agentHostProtocolClient.test.ts | Adds protocol client tests ensuring cert forwarding is pre-auth and resilient to reconnect races. |
| src/vs/platform/agentHost/test/common/ahpJsonlLogger.test.ts | Adds coverage ensuring certificate payloads are redacted in AHP logs. |
| src/vs/platform/agentHost/node/serviceBootstrapping.md | Documents new forwarding rules, lifecycle, and gating behavior. |
| src/vs/platform/agentHost/node/protocolServerHandler.ts | Adds the set-client-certificates extension method handling and capability advertisement. |
| src/vs/platform/agentHost/node/devContainerAgentHostService.ts | Adds Docker-locality detection and uses shared cert bundle writer. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Applies merged cert bundles only to the Copilot runtime env and restarts on certificate changes. |
| src/vs/platform/agentHost/node/agentHostRequestService.ts | Switches certificate loading to proxy resolver (combined native + client trust). |
| src/vs/platform/agentHost/node/agentHostProxyResolver.ts | Stores per-client certificates, validates PEM via X509, and exposes combined cert loading. |
| src/vs/platform/agentHost/electron-browser/wslRemoteAgentHostServiceImpl.ts | Enables certificate forwarding for WSL connections (gated by http.systemCertificates). |
| src/vs/platform/agentHost/common/meta/vscode/agentHostClientCertificatesMeta.ts | Adds capability meta key + helper for supported hosts. |
| src/vs/platform/agentHost/common/meta/agentHostClientCertificatesMeta.ts | Re-exports capability helper via common meta module. |
| src/vs/platform/agentHost/common/devContainerAgentHost.ts | Extends Dev Container connect result to indicate eligibility for forwarding. |
| src/vs/platform/agentHost/common/clientCertificatesProtocol.ts | Defines protocol method name and param validator. |
| src/vs/platform/agentHost/common/ahpJsonlLogger.ts | Redacts certificate payloads in JSONL request logging. |
| src/vs/platform/agentHost/common/agentHostExtensionProtocol.ts | Adds the new method to the extension server command map typing. |
| src/vs/platform/agentHost/browser/agentHostProtocolClient.ts | Sends certificates pre-auth on connect/reconnect with interruption guards. |
Review effort: Lite
Replace connection-time certificate pushes with a client-advertised reverse RPC. Cache and coalesce loads per connection, preserve prior trust on failures, discard stale replies, and refresh running Copilot runtimes only when trust changes. Normalize, sort, and deduplicate PEM bundles; skip malformed certificates with count-only warnings. Fix formatting reported by CI. Co-authored-by: Copilot <[email protected]>
Address review feedback by keeping injected service mocks on separate lines. Co-authored-by: Copilot <[email protected]>
Preserve both upstream worktree/container tests and certificate pull coverage, and wire the certificate resolver into new protocol tests. Co-authored-by: Copilot <[email protected]>
Keep client roots out of AH request-service certificate exports, follow Docker's DOCKER_HOST precedence when checking local containers, and make locality and Copilot bundle setup failures non-fatal. Co-authored-by: Copilot <[email protected]>
The Dev Container CLI launched by the Agent Host needs the client-supplied roots. Restore the combined request-service certificate export and document that both Copilot and the Dev Container CLI receive them through NODE_EXTRA_CA_CERTS. Co-authored-by: Copilot <[email protected]>
Load Agent Host native roots once and reuse the cached client pull for Copilot and the Agent Host's Dev Container CLI. Both write the same content-addressed NODE_EXTRA_CA_CERTS bundle under the Agent Host user data, which includes the existing NODE_EXTRA_CA_CERTS roots loaded by Node. Co-authored-by: Copilot <[email protected]>
…lient-certificates
The default account service was removed from AgentHostProtocolClient on main; stop passing it from the client certificate test. Co-authored-by: Copilot <[email protected]>
Recompute the shared NODE_EXTRA_CA_CERTS path before each Agent Host Dev Container CLI run from the resolver's cached native and per-connection client roots. Desktop Dev Containers keep resolving their bundle once. Co-authored-by: Copilot <[email protected]>
Cache a failed vscode/loadCertificates request for the rest of that connection instead of retrying on every use, which could delay each request by the 30-second timeout. Previously loaded trust is kept, and the next reconnect requests certificates again. Co-authored-by: Copilot <[email protected]>
Christof Marti (chrmarti)
marked this pull request as ready for review
October 28, 2026 10:30
Christof Marti (chrmarti)
enabled auto-merge
October 28, 2026 10:30
Aiday Marlen Kyzy (aiday-mar)
approved these changes
Oct 28, 2026
Christof Marti (chrmarti)
deleted the
chrmarti/agent-host-client-certificates
branch
October 28, 2026 11:04
Christof Marti (chrmarti)
added a commit
that referenced
this pull request
Nov 1, 2026
…cal containers (#345225) Related to #342540. An Agent Host in WSL or a local Dev Container now uses the client's proxy configuration and falls back to the client's Kerberos tickets, the same way a remote extension host with `useHostProxy` does (`proxyResolver.ts`). This covers the Agents window's WSL and Dev Container connections and editor windows connected to WSL or Dev Containers. ## Changes - **Which connections.** WSL always counts. A Dev Container counts only when the existing certificate-forwarding detection (#343431) finds a local Docker endpoint: `DOCKER_HOST`, then the active context, must be `unix://` or `npipe://`. The flag is renamed from `forwardClientCertificates` to `sharesClientNetwork`, since certificates, proxy and Kerberos now all depend on it. Editor-window remotes use the same `useHostProxy` gate as certificates. - **Proxy resolution.** Such clients advertise `vscode.clientProxy` and serve `vscode/resolveProxy`. While one is connected, the Agent Host resolves proxies through it after `http.proxy` and the proxy environment variables. PAC and system proxies resolved on the client therefore apply to the Agent Host's own requests and to the Copilot runtime's `HTTPS_PROXY`. As for a remote extension host, `http.useLocalProxyConfiguration: false` turns this off. - **Kerberos.** The Agent Host and the Copilot runtime use their own tickets first and fall back to `vscode/lookupProxyKerberosAuthorization`. The client answers through `IRequestService.lookupKerberosAuthorization`, which uses the platform's principal syntax (`HTTP@host` on macOS and Linux) and honors `http.proxyKerberosServicePrincipal`. It only issues tickets for proxies it points the Agent Host at: its `http.proxy` setting, proxies it resolved for that Agent Host, or its system proxy for GitHub Copilot. With a principal override configured, tickets are only for that principal. - **Copilot runtime.** The runtime's fallback uses the SDK `kerberosAuth` option from github/copilot-agent-runtime#30203 (`mode: 'fallback'`, `scope: 'runtime'`). Desktop and remote now pin the Universe SDK build `1.0.27-unstable.41214319014.g4f70995`, with runtime `1.0.103-unstable.r41214319014.g4f70995`, which includes it (github/copilot-agent-runtime#31352). The option is type-checked against the SDK's own `KerberosAuthConfig`, replacing the local declaration that older SDKs ignored. Besides the callback, the build brings the Universe branch's other changes since the previous pin, including the Entra token callbacks (github/copilot-agent-runtime#30708). - **Smoke tests.** Two opt-in suites and their Windows runner `test/smoke/scripts/run-agents-window-wsl-kerberos-proxy.ps1` cover an Agent Host in WSL that reaches the HTTPS mock model server only through a Kerberos-authenticated Squid proxy. `Agents Window (WSL AgentHost, Kerberos proxy)` starts the Agent Host from the Agents window. `Editor Window (WSL remote AgentHost, Kerberos proxy)` opens an editor window on a VS Code server in WSL, which spawns the Agent Host. - The proxy comes from a Windows PAC. The Kerberos tickets come from a network-only logon to a test realm whose KDC runs in WSL. The mock server's CA comes from the Windows trust store. WSL gets none of them, and its ticket cache is empty. - The Agents window suite checks that the client answered `vscode/resolveProxy` with the PAC's proxy and returned a Kerberos token and certificates. - The editor window suite opens an Agent Host Copilot chat editor (new `smoketest.openAgentHostChat` helper) and waits for the reply and its model request. That connection writes no protocol transcript, so it checks the server's Agent Host log for the mock CAPI URL and the client-resolved proxy. - For that suite, the test resolver resolves `wsl+<distribution>` when the fixture passes the server command in `TESTRESOLVER_WSL_SERVER_COMMAND`. It starts the server in WSL with `--use-host-proxy`, like the WSL extension does, and waits until WSL forwards the server's port to Windows. The automation's new `remoteAuthority` option opens the workspace with that authority. The remote window gets its own extensions directory, because a packaged build's late copy of the test resolver into the shared one is dropped once an earlier window registered it. - The runner checks the authenticated tunnels in Squid's log and the tickets the KDC issued to Windows, and reverts all machine changes. - The runner prompts for administrator rights unless it already runs elevated, as on CI agents; in CI it fails instead of prompting. `connectWSLHost` can now wait for a folder entry other than `.devcontainer`. - They are not in CI yet. Once a published Insiders server contains this change, a follow-up will pin it like the WSL Dev Container suite does, install the KDC and Squid packages in the CI WSL distribution, and run the runner in the WSL smoke shard. - **Local model test.** The new runtime attributes `/auto` routing requests to the session whose turn they route, so `copilotLocalModel.integrationTest.ts` now expects that session there. ## How to test 1. On Windows, behind a proxy that requires Kerberos (Negotiate), open the Agents window and connect to a WSL distro without its own Kerberos tickets. 2. Start a Copilot session. The Agent Host log shows the proxy resolved through the client, and Agent Host and Copilot runtime requests through the proxy succeed with the Windows user's tickets. 3. Repeat with a Dev Container on local Docker Desktop, and with an editor window connected to WSL. 4. Set `http.useLocalProxyConfiguration` to `false`: the Agent Host no longer resolves proxies through the client. Or run the smoke tests, with the distro packages and WSL source checkout described in `test/smoke/README.md`: ```powershell .\test\smoke\scripts\run-agents-window-wsl-kerberos-proxy.ps1 -Distribution Ubuntu -WslServerPath ~/devel/vscode -WslNodePath ~/.local/node/bin/node ``` ## Validation - Rebased on `main` at `8fb60541db0`. The conflicts were in `agentHostProtocolClient.ts` and `copilotAgent.test.ts`, where `main` added a `resourceUris` client option and an `IRequestService` parameter to `CopilotAgent`; both were kept. - `npm run typecheck-client`: passed after the rebase, against the new SDK. - `npm run build-fast -- --client-only`: passed after the rebase. - `npm run valid-layers-check`: passed, before an earlier rebase; no later commit changes imports across layers. - `npm run eslint -- <changed files>`: passed. - `scripts\test.bat --reporter dot --run src\vs\platform\agentHost\test\browser\agentHostClientProxy.test.ts --run src\vs\platform\agentHost\test\common\agentHostConfigurationSync.test.ts --run src\vs\platform\agentHost\test\electron-browser\agentHostProtocolClient.test.ts --run src\vs\platform\agentHost\test\electron-browser\localAgentHostService.test.ts --run src\vs\platform\agentHost\test\node\agentHostRequestService.test.ts --run src\vs\platform\agentHost\test\node\copilotAgent.test.ts --run src\vs\platform\agentHost\test\node\protocolServerHandler.test.ts --run src\vs\sessions\contrib\providers\remoteAgentHost\test\electron-browser\devContainerAgentHostConnector.test.ts`: 1988 passing, 1 pending, after the rebase. - `scripts\test-integration.bat --run src/vs/platform/agentHost/test/node/e2e/providers/copilotAgentHostE2E.integrationTest.ts`, Copilot Agent Host E2E replay with the new SDK: 251 passing, 53 pending, 1 failing. - The failure is `server tool: create_session materializes a selected-model child session and starts its prompt`: the child chat's title was still empty when read after the chat went idle. - The test passed in two isolated reruns with `--grep`. No fixtures changed. - `scripts\test-integration.bat --run src/vs/platform/agentHost/test/node/providerIntegration/copilotLocalModel.integrationTest.ts`: 10 passing with the updated `/auto` expectation. It had failed on all three platforms in PR CI after the SDK bump. - Azure build [491685](https://dev.azure.com/monacotools/Monaco/_build/results?buildId=491685) of `337fa77f364`: full product build with tests on all platforms, without publishing. All compile and test jobs passed; the macOS signing jobs were still running when this was marked ready. Build 491683 found that the client proxy unit tests depended on the build agent's `http_proxy`; they now use a resolver that ignores proxy environment variables. - Azure build [491659](https://dev.azure.com/monacotools/Monaco/_build/results?buildId=491659) of `03eef985b77` built Windows x64 and Linux x64 artifacts, without publishing or tests. The smoke tests passed elevated against its packaged Insiders client (`--build`) and its Linux server extracted in WSL, which is how CI will run them. The WSL Agent Host used the server's bundled runtime. - With the editor window suite (`f3944fb70ae`, before the rebase), both suites passed in one run (`-ProxyScheme Http`). In the editor window suite, the server-spawned Agent Host used the mock CAPI URL and the client-resolved proxy, and its runtime logged `native Kerberos credentials unavailable; trying Kerberos callback`. - `npm run compile` in `test/smoke`, `npm run gulp compile-extension:vscode-test-resolver` and `npm run eslint -- <changed files>` passed for this commit. - The Agents window smoke test passed on Windows 11 with Ubuntu in WSL, using the bundled Linux runtime of the new SDK and no runtime override. - This run used a source checkout in WSL and ran elevated, so the machine configuration was applied without prompts, as on a CI agent. - An earlier revision of the runner also passed unelevated, with its two administrator prompts. The prompted path now passes its arguments differently; I checked the new quoting by having an unelevated stand-in script record the parameters it received. - The WSL runtime's own Kerberos lookup failed, it fell back to the callback, and Squid logged Kerberos-authenticated tunnels for the client's user. The machine configuration was restored afterwards. - Not tested end to end: Dev Containers, editor windows through the WSL extension rather than the test resolver, and macOS and Linux clients.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Related to #342540. This addresses certificate trust for Agent Host Copilot sessions; Kerberos/proxy authentication is unchanged.
Summary
DOCKER_HOST, then the active context. Unknown endpoints and locality-check failures are treated as remote without failing the container connection.vscode/loadCertificates, using the existing reverse-RPC transport and the client's certificate loader. Connecting does not push certificates or wait for a transfer.NODE_EXTRA_CA_CERTSbundle as loaded by Node, are loaded once; client roots are pulled once per connection.NODE_EXTRA_CA_CERTSbundle of that set under the AH user data. Copilot uses it when client roots are present; the AH's Dev Container CLI always uses it instead of a supplied file and refreshes the path from those cached roots before each CLI run. Desktop-launched Dev Containers keep Remote Containers' behaviour of resolving their bundle once. If the bundle cannot be written, both start with their existing environments and log a warning.http.systemCertificatesgates certificate serving. No new setting is introduced.Validation
Merged current
origin/mainand validated on Windows with Node 24.22.1 and updated dependencies.npm run build-fast -- --client-only- passed.npm run typecheck-client- passed.$files = @(git diff --name-only origin/main -- '*.ts'); node build\lib\formatter.ts --verify $files- passed, including the file previously reported by CI hygiene.$files = @(git diff --name-only origin/main -- '*.ts'); npm run eslint -- $files- passed for 31 changed TypeScript files.npm run valid-layers-check- passed.git diff --check- passed.Full affected connection, trust, logging, and lifecycle suites before the review revision: 1,061 passed, 2 platform-specific skips.
Shared certificate bundle validation:
npx tsc --project ./src/tsconfig.json --noEmit --skipLibCheck- passed.npm run build-fast -- --client-only- passed.node build\lib\formatter.ts --verify <8 changed TypeScript files>- passed.npm run eslint -- <8 changed TypeScript files>- passed.git diff --check- passed..\scripts\test.bat --run src\vs\platform\request\test\node\certificates.test.ts --run src\vs\platform\agentHost\test\node\agentHostRequestService.test.ts --run src\vs\platform\agentHost\test\node\devContainerAgentHostService.test.ts --run src\vs\platform\agentHost\test\node\devContainerSamples.test.ts --run src\vs\platform\agentHost\test\node\protocolServerHandler.test.ts --run src\vs\platform\agentHost\test\node\agentHostServices.test.ts --run src\vs\platform\agentHost\test\node\agentHostBootstrap.test.ts --reporter dot- 610 passed, 2 pending..\scripts\test.bat --run src\vs\platform\agentHost\test\node\copilotAgent.test.ts --grep '[Cc]ertificat' --reporter dot- 3 passed, including pull-before-start, runtime refresh with the shared bundle, and non-fatal bundle-write failure.Latest merge and CI-fix validation (current
origin/mainmerged; dependencies refreshed withnpm run install-fast):npm run build-fast -- --client-only- passed.npx tsc --project ./src/tsconfig.json --noEmit --skipLibCheck- passed.node build\lib\formatter.ts --verify <3 changed TypeScript files>- passed.npm run eslint -- <3 changed TypeScript files>- passed.git diff --check- passed..\scripts\test.bat --run src\vs\platform\agentHost\test\electron-browser\agentHostProtocolClient.test.ts --run src\vs\platform\request\test\node\certificates.test.ts --run src\vs\platform\agentHost\test\node\agentHostRequestService.test.ts --run src\vs\platform\agentHost\test\node\devContainerAgentHostService.test.ts --run src\vs\platform\agentHost\test\node\devContainerSamples.test.ts --run src\vs\platform\agentHost\test\node\protocolServerHandler.test.ts --run src\vs\platform\agentHost\test\node\agentHostServices.test.ts --run src\vs\platform\agentHost\test\node\agentHostBootstrap.test.ts --run src\vs\platform\agentHost\test\node\agentHostTcp.test.ts --run src\vs\platform\agentHost\test\common\ahpJsonlLogger.test.ts --run src\vs\workbench\services\agentHost\test\browser\editorRemoteAgentHostServiceClient.test.ts --run src\vs\sessions\contrib\providers\remoteAgentHost\test\electron-browser\devContainerAgentHostConnector.test.ts --reporter dot- 1,069 passed, 2 pending, including the protocol-client certificate tests that failed in CI..\scripts\test.bat --run src\vs\platform\agentHost\test\node\copilotAgent.test.ts --grep '[Cc]ertificat' --reporter dot- 3 passed.No-retry validation:
npx tsc --project ./src/tsconfig.json --noEmit --skipLibCheck- passed.node build\lib\formatter.ts --verify <3 changed TypeScript files>,npm run eslint -- <3 changed TypeScript files>, andgit diff --check- passed..\scripts\test.bat --run src\vs\platform\agentHost\test\node\agentHostRequestService.test.ts --run src\vs\platform\agentHost\test\node\protocolServerHandler.test.ts --run src\vs\platform\agentHost\test\electron-browser\agentHostProtocolClient.test.ts --run src\vs\platform\agentHost\test\node\devContainerAgentHostService.test.ts --reporter dot- 940 passed, 2 pending..\scripts\test.bat --run src\vs\platform\agentHost\test\node\copilotAgent.test.ts --grep '[Cc]ertificat' --reporter dot- 3 passed.Manual follow-up
Live corporate-proxy flows were not exercised. With proxy authentication already working, test a client-only corporate CA in WSL and a local Dev Container, including an existing remote
NODE_EXTRA_CA_CERTSbundle. Verify Copilot and the AH's Dev Container CLI use the same bundle containing native, existing, and client roots, the original file remains unchanged, and reconnecting refreshes Copilot trust. Verify SSH, tunnel, and remote-container connections do not receive client certificates. Full integration and smoke suites were not run locally.