fix(mcp): support NODE_EXTRA_CA_CERTS for enterprise MITM proxies#2271
Merged
fahreddinozcan merged 2 commits intoupstash:masterfrom Mar 19, 2026
Merged
Conversation
When NODE_EXTRA_CA_CERTS is set, reads the CA certificate file and injects it into undici's global dispatcher. This fixes fetch failures behind enterprise transparent SSL intercept proxies (Zscaler, etc.) where the default TLS context does not trust the corporate CA. The CA certs are also passed through when an explicit HTTPS_PROXY is configured, so both proxy modes work with custom certificates. Fixes upstash#2268 This contribution was developed with AI assistance (Claude Code). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fahreddinozcan
approved these changes
Mar 19, 2026
Contributor
Author
|
Thanks for the quick review and merge on both PRs. |
This was referenced Apr 9, 2026
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.
Summary
NODE_EXTRA_CA_CERTSand injects them into undici's global dispatcher at runtimesetGlobalDispatcher+undicipattern already used for HTTP proxy supportProblem
Behind enterprise MITM proxies (Zscaler, corporate VPNs), Node's default
fetch()TLS context does not trust the corporate CA certificate. Even whenNODE_EXTRA_CA_CERTSis set, many MCP client launchers (npx, background daemons) strip or inject the env var too late for Node to pick it up at startup, causingUNABLE_TO_VERIFY_LEAF_SIGNATUREerrors.Solution
Explicitly read the CA cert file at module load time and pass it to undici's
AgentorProxyAgentvia theconnect.caoption. This bypasses Node's frozen TLS context and works regardless of when the env var was set.Three cases are handled:
ProxyAgentgets both the proxy URI and the CA certAgentwith the CA cert is set as the global dispatcherFixes #2268
This contribution was developed with AI assistance (Claude Code).