<!-- https://pkizerotohero.com/guides/mcp-server-certificate-errors/ | Markdown mirror of the HTML page | PKI Zero to Hero, by Duyutech BV -->

> Fix SELF_SIGNED_CERT_IN_CHAIN and OAuth failures on MCP servers behind a TLS-inspecting proxy: find the process that connects and give it the proxy root.

Source: https://pkizerotohero.com/guides/mcp-server-certificate-errors/ · Last reviewed: 2026-10-24

How-to guide · Trust a CA

# How to fix MCP server certificate errors behind a corporate proxy

**In one sentence:**

You will have found which process opens the TLS connection to your MCP server and put the proxy root where that process reads it, with verification still on.

Task

[Trust a CA](https://pkizerotohero.com/guides/#task-trust)

Platforms

- Linux
- macOS
- Windows

Who it is for

- [Developer](https://pkizerotohero.com/start/#developer)
- [IT ops](https://pkizerotohero.com/start/#itops)

Level

Practitioner · 5 steps

## Before you start

- **The exact string.** From a Node-based server or mcp-remote: `SELF_SIGNED_CERT_IN_CHAIN`, `UNABLE_TO_GET_ISSUER_CERT_LOCALLY` or `UNABLE_TO_VERIFY_LEAF_SIGNATURE`, often wrapped in a bare `fetch failed`. Around OAuth sign-in: `OAuth error: fetch failed` or `SDK auth failed: self signed certificate in certificate chain`. Sometimes only `Server disconnected`, or a Cursor server that stays on Loading.
- **The proxy’s root certificate as a PEM file**, obtained through a trusted channel as [How to work behind a TLS-inspecting corporate proxy](https://pkizerotohero.com/guides/corporate-proxy-certificates/) describes; on Linux the system bundle `/etc/ssl/certs/ca-certificates.crt` serves once IT’s root is in it.
- **Write access to the client’s configuration file**, and a terminal.

A [TLS-inspecting](https://pkizerotohero.com/handbook/glossary/#tls-inspection) proxy re-signs every HTTPS connection with its own [certificate authority](https://pkizerotohero.com/handbook/glossary/#certificate-authority). Your browser accepts that because IT put the proxy’s [root certificate](https://pkizerotohero.com/handbook/glossary/#root-certificate) in the operating system’s [trust store](https://pkizerotohero.com/handbook/glossary/#trust-store); the process that connects to your MCP server usually never looks there. Find that process and give it the root, with verification left on.

## Steps

### 1. Confirm the proxy is in the path

Ask the MCP host who signed its certificate:

```bash
openssl s_client -showcerts -connect mcp.example.com:443 -servername mcp.example.com </dev/null 2>/dev/null \
  | openssl x509 -noout -subject -issuer
```

```text
subject=CN = mcp.example.com
issuer=C = BE, O = Example Corp, CN = Example Corp TLS Inspection Root
```

A public [issuer](https://pkizerotohero.com/handbook/glossary/#issuer) means this host is not inspected (a failure then points at the server’s own chain: [check it](https://pkizerotohero.com/guides/check-remote-certificate-chain/)); your company or proxy vendor as issuer means re-signing. Then ask Node, which most stdio servers and mcp-remote run on:

```bash
node -e "fetch('https://mcp.example.com/mcp').then(r => console.log(r.status)).catch(e => console.error(e.cause?.code ?? e))"
```

Any HTTP status, even 401 or 405, means the [TLS handshake](https://pkizerotohero.com/handbook/glossary/#tls-handshake) succeeded. `SELF_SIGNED_CERT_IN_CHAIN` means the proxy’s root is in the [chain](https://pkizerotohero.com/handbook/glossary/#certificate-chain) and Node holds no copy of it; `UNABLE_TO_GET_ISSUER_CERT_LOCALLY` means the chain stops at an [intermediate](https://pkizerotohero.com/handbook/glossary/#intermediate-certificate) Node cannot link to a root it has. Both take the same fix. Run it again with `NODE_EXTRA_CA_CERTS=~/corp-root.pem` in front of `node`: a status code proves your PEM file.

### 2. Find which process opens the connection

The setting must reach the process that performs the handshake, which depends on the transport. Streamable HTTP replaced the separate SSE transport in protocol revision 2025-03-26, but both are connections the client opens itself.

| Transport | Who opens the TLS connection | Where the setting lives |
| --- | --- | --- |
| stdio, including mcp-remote | the server subprocess the client launches | that server’s `env` block in the client’s config file |
| Streamable HTTP or SSE as a `url` | the client itself | the client’s own certificate setting (step 4) |
| OAuth sign-in to a hosted server | the client (discovery and tokens) and your browser (sign-in page) | the client’s setting; the OS store for the browser |

A GUI client never runs your shell profile, and the MCP debugging guide says stdio servers inherit only a limited, platform-dependent subset of environment variables. Claude Code in a terminal does pass its shell environment on unless `CLAUDE_CODE_MCP_ALLOWLIST_ENV=1` is set, which is why an `export` in `.zshrc` works there and nowhere else. Claude Code itself is a native binary, for npm installs too since v2.1.113, with its own certificate setting rather than Node’s.

### 3. Put the setting where that process reads it

For a stdio server, the variable goes in the server’s `env` block. Claude Desktop, `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "remote-tools": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.example.com/mcp"],
      "env": { "NODE_EXTRA_CA_CERTS": "/Users/you/corp-root.pem" }
    }
  }
}
```

Claude Code, `.mcp.json` in the project or `~/.claude.json`; a `url` entry needs `"type": "http"`, because an entry with a `url` and no `type` is read as stdio:

```json
{
  "mcpServers": {
    "local-tools": {
      "command": "npx",
      "args": ["-y", "@example/mcp-server"],
      "env": { "NODE_EXTRA_CA_CERTS": "/home/you/corp-root.pem" }
    },
    "hosted-tools": { "type": "http", "url": "https://mcp.example.com/mcp" }
  }
}
```

Cursor, `~/.cursor/mcp.json` or `.cursor/mcp.json`; an `envFile` key can hold the same variable. On Windows, double the backslashes:

```json
{
  "mcpServers": {
    "remote-tools": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.example.com/mcp"],
      "env": { "NODE_EXTRA_CA_CERTS": "C:\\certs\\corp-root.pem" }
    }
  }
}
```

VS Code, `.vscode/mcp.json` or the user `mcp.json`, with a `servers` object and a `type`:

```json
{
  "servers": {
    "remote-tools": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.example.com/mcp"],
      "env": { "NODE_EXTRA_CA_CERTS": "/Users/you/corp-root.pem" }
    }
  }
}
```

To use the OS store instead, replace the variable with `"NODE_USE_SYSTEM_CA": "1"` on Node 22.19.0 and 24.6.0 or later, or `"NODE_OPTIONS": "--use-system-ca"` on Node 22.15.0 or later before that. Under `bunx`, Bun has honoured `NODE_EXTRA_CA_CERTS` since bun 1.1.22 and reads `NODE_USE_SYSTEM_CA=1` too.

For Claude Code’s own connections (`url` entries, OAuth sign-in and claude.ai connectors), the native binary reads the OS store as well as its bundled roots, since `CLAUDE_CODE_CERT_STORE` defaults to bundled,system; a root IT installed there needs nothing more. A root that exists only as a file goes in the `env` block of `~/.claude/settings.json`, which background agents and the Desktop app’s Code tab read too:

```json
{
  "env": { "NODE_EXTRA_CA_CERTS": "/Users/you/corp-root.pem" }
}
```

An older npm install still running on your own Node takes `NODE_EXTRA_CA_CERTS` the same way, and `--use-system-ca` only on Node 22.15.0 or later.

Warning

Never fix this with NODE\_TLS\_REJECT\_UNAUTHORIZED

The snippet people paste is `"env": { "NODE_TLS_REJECT_UNAUTHORIZED": "0" }`. Node’s reference says it disables certificate validation for the process and is strongly discouraged; Claude Code’s error reference says not to set it. An MCP server holds your OAuth tokens and API keys and would hand them to anything answering on port 443, while silencing every certificate error you have not diagnosed yet, including a real [man-in-the-middle](https://pkizerotohero.com/handbook/glossary/#man-in-the-middle). The one proxy root keeps every other check in place.

### 4. Match the transport

- **stdio, including mcp-remote:** the `env` block from step 3 is the whole fix, in every client.
- **Streamable HTTP or SSE as a `url`:** the client connects. Claude Code uses the setting above. VS Code loads the OS store while `http.systemCertificates` is true, its default, so add the proxy root there: [macOS](https://pkizerotohero.com/guides/add-root-ca-macos/), [Windows](https://pkizerotohero.com/guides/add-root-ca-windows/) or [Linux](https://pkizerotohero.com/guides/add-root-ca-linux/). Cursor documents no certificate setting for its own HTTP transport: run the server through mcp-remote as stdio, or exclude the host at the proxy (step 5).
- **Hosted OAuth:** the client’s setting covers discovery and token fetches; the sign-in page opens in your browser, which uses the OS store. Claude Desktop reaches custom connectors from Anthropic’s infrastructure, not from your machine, so only its local stdio servers need anything.

### 5. Or exclude the MCP hosts from inspection

No client configuration needed. Ask the proxy team to exclude the MCP host, its OAuth authorisation server and, for claude.ai connectors used from Claude Code, `mcp-proxy.anthropic.com` from TLS inspection. Cursor’s network page notes that some enterprise proxies mishandle HTTP/2 streaming and requires SSE passthrough without buffering from any proxy that inspects. That matters for MCP too: Streamable HTTP carries server messages over SSE, so a buffering proxy leaves a server that connects and never answers a tool call. Exclusion fixes both.

## Check it worked

Restart the client fully: Node reads `NODE_EXTRA_CA_CERTS` once at process start, and for Claude Desktop closing the window is not enough, quit it. Then, in Claude Code:

```bash
claude mcp list
```

```text
remote-tools: npx -y mcp-remote https://mcp.example.com/mcp - ✔ Connected
```

A failing server shows `✘ Failed to connect` with the error appended, and `claude mcp get remote-tools` repeats it on an `Issue:` line; `! Needs authentication` means TLS worked. Start with `claude --debug` and look in `~/.claude/debug/<session-id>.txt` for `CA certs: Appended extra certificates from NODE_EXTRA_CA_CERTS`, the proof the file was read. Claude Desktop writes `mcp.log` and `mcp-server-NAME.log` (the server’s stderr) under `~/Library/Logs/Claude` or `%APPDATA%\Claude\logs`; Cursor shows MCP Logs in the Output panel (Cmd+Shift+U); VS Code offers Show Output from MCP: List Servers; mcp-remote with `"--debug"` in `args` writes `~/.mcp-auth/<server-hash>_debug.log`.

The chain checker names inspection products:

*Interactive tool: Chain checker (runs in the browser at [/tools/chain/](https://pkizerotohero.com/tools/chain/))*

## If something goes wrong

- **Works in the terminal, fails in the app:** the shell export is not reaching the subprocess; move it into the server’s `env` block. The code is Node’s: [SELF\_SIGNED\_CERT\_IN\_CHAIN](https://pkizerotohero.com/errors/node-self-signed-cert-in-chain/).
- **Claude Code OAuth sign-in fails with `SDK auth failed: self signed certificate in certificate chain` while `claude mcp list` connects:** issue #55760 in anthropics/claude-code reports that from v2.1.113 the OAuth initiation path ignored `NODE_EXTRA_CA_CERTS`; the project marked it fixed in v2.1.133, so run `claude update`. An OAuth failure no CA setting touches may be the discovery regression reported in issue #66456. See the [Claude Code error page](https://pkizerotohero.com/errors/claude-code-self-signed-cert-in-chain/).
- **`UNABLE_TO_VERIFY_LEAF_SIGNATURE` persists:** the proxy may be sending only the [leaf](https://pkizerotohero.com/handbook/glossary/#leaf-certificate); [UNABLE\_TO\_VERIFY\_LEAF\_SIGNATURE](https://pkizerotohero.com/errors/node-unable-to-verify-leaf-signature/) shows how to tell.
- **`npx` cannot fetch the package:** that download is npm’s own, before the server starts: [UNABLE\_TO\_GET\_ISSUER\_CERT\_LOCALLY](https://pkizerotohero.com/errors/npm-unable-to-get-issuer-cert-locally/).
- **A bare `fetch failed`, a Cursor server stuck on Loading, or a server listed without tools:** the client’s log above, or the Node one-liner from step 1, prints the inner code. The editors’ own stores: [VS Code / Cursor: self signed certificate in certificate chain](https://pkizerotohero.com/errors/vscode-self-signed-certificate-in-certificate-chain/).
- **mcp-remote keeps failing:** clear its cache with `rm -rf ~/.mcp-auth`; if the proxy must be addressed explicitly, add `"--enable-proxy"` to `args` and `HTTPS_PROXY` to `env`.

## Why this works

A client accepts a chain only when it can link it to a root already in the trust store it reads, and behind an inspecting proxy every chain ends at the proxy’s root. Each runtime keeps its own store: the browser reads the operating system’s, Node ships its own bundle and ignores the OS store unless told to, and the native Claude Code binary reads both. So the browser working proves nothing about the subprocess your client launched; the fix is the one root in the one store that process reads. [Who do we trust?](https://pkizerotohero.com/handbook/trust-stores/) explains trust stores and TLS inspection; [Certificate chains](https://pkizerotohero.com/handbook/certificate-chains/) explains path validation up to a trust anchor.

## Go deeper

- [MCP transports](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports) and the [MCP debugging guide](https://modelcontextprotocol.io/docs/tools/debugging).
- [Claude Code network configuration](https://code.claude.com/docs/en/network-config) and [MCP in Claude Code](https://code.claude.com/docs/en/mcp): `CLAUDE_CODE_CERT_STORE` and the `type` rule.
- [Cursor network configuration](https://cursor.com/docs/enterprise/network-configuration) and [Cursor MCP](https://cursor.com/docs/context/mcp).
- [VS Code MCP configuration reference](https://code.visualstudio.com/docs/agents/reference/mcp-configuration), [Manage MCP servers](https://code.visualstudio.com/docs/agents/run/manage-mcp-servers) and [Network connections](https://code.visualstudio.com/docs/setup/network).
- [Node.js CLI reference](https://nodejs.org/api/cli.html#node_extra_ca_certsfile): `NODE_EXTRA_CA_CERTS`, `--use-system-ca`, `NODE_USE_SYSTEM_CA`.
- [Bun environment variables](https://bun.com/docs/runtime/env) and the [mcp-remote README](https://github.com/geelen/mcp-remote).

**Early edition.** Written with AI assistance and checked against primary sources; an independent expert review is planned. Found a mistake? [Tell us](https://pkizerotohero.com/contact/?topic=content-error&page=/guides/mcp-server-certificate-errors/).

Last reviewed 24 October 2026Edition 0.9

## Keep going

### Learn why it works

- [Chapter 12: Who do we trust? CAs, trust stores and self-signed certificates](https://pkizerotohero.com/handbook/trust-stores/)
- [Chapter 13: Certificate chains and path validation](https://pkizerotohero.com/handbook/certificate-chains/)

### Error pages

- [SELF\_SIGNED\_CERT\_IN\_CHAIN](https://pkizerotohero.com/errors/node-self-signed-cert-in-chain/)
- [UNABLE\_TO\_VERIFY\_LEAF\_SIGNATURE](https://pkizerotohero.com/errors/node-unable-to-verify-leaf-signature/)
- [UNABLE\_TO\_GET\_ISSUER\_CERT\_LOCALLY](https://pkizerotohero.com/errors/npm-unable-to-get-issuer-cert-locally/)

### Tools

- [Chain checker](https://pkizerotohero.com/tools/chain/): Paste a chain and see which link is missing, expired or out of order.

### Topics

- [Chains and trust stores](https://pkizerotohero.com/topics/chains-and-trust/)

## More guides: Trust a CA

- [How to work behind a TLS-inspecting corporate proxy, safely](https://pkizerotohero.com/guides/corporate-proxy-certificates/)
- [How to trust a private root CA on Windows](https://pkizerotohero.com/guides/add-root-ca-windows/)
- [How to trust a private root CA on macOS](https://pkizerotohero.com/guides/add-root-ca-macos/)
- [How to trust a private root CA on Linux](https://pkizerotohero.com/guides/add-root-ca-linux/)
- [How to add a CA to a Java trust store (cacerts)](https://pkizerotohero.com/guides/add-root-ca-java/)
- [How to make Python, Node.js and npm trust a private CA](https://pkizerotohero.com/guides/trust-ca-python-node/)
