<!-- https://pkizerotohero.com/errors/claude-code-self-signed-cert-in-chain/ | Markdown mirror of the HTML page | PKI Zero to Hero, by Duyutech BV -->

> Why Claude Code prints SELF_SIGNED_CERT_IN_CHAIN behind a TLS-inspecting proxy, which of its four trust paths rejected the chain, and the fix for each.

Source: https://pkizerotohero.com/errors/claude-code-self-signed-cert-in-chain/ · Last reviewed: 2026-10-24

- Claude Code

# Claude Code: self signed certificate in certificate chain

Also seen in: the VS Code extension, Claude Desktop, WSL, MCP servers, the installer

**In one sentence:**

Claude Code is several processes with several trust stores; find which one rejected the proxy's root, then give that store the root instead of switching verification off.

[Check yours: Chain checker](https://pkizerotohero.com/tools/chain/)

## Where you see it

The CLI prints this when it cannot verify `api.anthropic.com`:

```text
Unable to connect to API: Self-signed certificate detected (SELF_SIGNED_CERT_IN_CHAIN)
```

Its sibling `Unable to connect to API: SSL certificate verification failed` carries `UNABLE_TO_GET_ISSUER_CERT_LOCALLY`, and `/login` shows `SSL certificate error (...)`. Since v2.1.273 the message carries the OpenSSL code and a `NODE_EXTRA_CA_CERTS` hint; before that it ended at `Check your proxy or corporate SSL certificates`. Since v2.1.199 it is reported at once, not after retries. The VS Code extension’s dictation and Web tab print `Dictation error: WebSocket error:`, the installer prints `Failed to fetch version from downloads.claude.ai`, and an MCP server fails in its own runtime’s words.

## What it means

The code is OpenSSL’s: the [certificate chain](https://pkizerotohero.com/handbook/glossary/#certificate-chain) the process received ends in a [self-signed certificate](https://pkizerotohero.com/handbook/glossary/#self-signed-certificate) missing from the [trust store](https://pkizerotohero.com/handbook/glossary/#trust-store) that process reads. On a managed laptop that root is a [TLS-inspecting](https://pkizerotohero.com/handbook/glossary/#tls-inspection) proxy’s [private CA](https://pkizerotohero.com/handbook/glossary/#private-ca), pushed into the OS store, so your browser accepts it. Claude Code crosses four trust paths in one session:

1. **The native binary** (Bun): bundled Mozilla roots plus the OS store, per `CLAUDE_CODE_CERT_STORE`, plus `NODE_EXTRA_CA_CERTS`.
2. **Node-hosted parts**: the VS Code extension’s dictation and Web tab, and older npm packages’ CLI, with Node’s bundled roots only.
3. **MCP stdio servers**: child processes with their own store.
4. **The installer**: the script downloads with curl or .NET and the OS store; the new binary then fetches the release version itself.

## Likely causes

### A TLS-inspecting proxy, and the native binary cannot find its root

Read the chain:

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

```text
subject=CN=api.anthropic.com
issuer=O=Example Corp, CN=Example Corp TLS Inspection CA
```

An [issuer](https://pkizerotohero.com/handbook/glossary/#issuer) that is your employer confirms interception. Compare with curl, which reads the OS store:

```bash
curl -sSv https://api.anthropic.com/ -o /dev/null 2>&1 | grep -E 'issuer:|certificate problem'
```

If curl fails too, install the root in the OS store ([Linux](https://pkizerotohero.com/guides/add-root-ca-linux/), [macOS](https://pkizerotohero.com/guides/add-root-ca-macos/), [Windows](https://pkizerotohero.com/guides/add-root-ca-windows/)) and leave `CLAUDE_CODE_CERT_STORE` at its default of bundled,system, the default since 2.1.101.

If curl succeeds and `claude` fails, the failing process reads a different store. `claude --debug` logs `CA certs: Appended extra certificates from NODE_EXTRA_CA_CERTS (/path/to/ca.pem)`, or `Failed to read` or `Failed to load` for a bad path, in `~/.claude/debug/<session-id>.txt`; `/status` does not check the file.

Otherwise export the proxy root as PEM for `NODE_EXTRA_CA_CERTS`. Windows (DER out, then PEM):

```powershell
Get-ChildItem Cert:\LocalMachine\Root | Where-Object Subject -like '*Example Corp*' |
  Select-Object -First 1 | Export-Certificate -FilePath C:\certs\proxy-root.cer
certutil -encode C:\certs\proxy-root.cer C:\certs\proxy-root.pem
```

macOS:

```bash
security find-certificate -a -c "Example Corp" -p /Library/Keychains/System.keychain > ~/proxy-root.pem
```

Linux: the merged bundle, `/etc/ssl/certs/ca-certificates.crt` (Debian, Ubuntu) or `/etc/pki/tls/certs/ca-bundle.crt` (Fedora, RHEL). Set it in the `env` block of `~/.claude/settings.json`, which reaches every background-agent session, with `CLAUDE_CODE_CERT_STORE` beside it.

```json
{
  "env": {
    "NODE_EXTRA_CA_CERTS": "/etc/ssl/certs/ca-certificates.crt"
  }
}
```

They do not stack:

| Setting | Affects | Effect |
| --- | --- | --- |
| `CLAUDE_CODE_CERT_STORE` | binary | base stores: `bundled`, `system`, both |
| `NODE_EXTRA_CA_CERTS` | binary, Node, extension | one PEM file, read at launch |
| `NODE_USE_SYSTEM_CA=1` | Node | adds the OS store; undocumented for Claude Code |
| `NODE_OPTIONS=--use-system-ca` | Node adds, Claude Code replaces | keeps only the OS store; public sites fail |

### The npm-installed CLI or the VS Code extension runs on Node

The VS Code chat panel uses the extension’s bundled binary: the fix above covers it. Dictation and the Web tab read `NODE_EXTRA_CA_CERTS` from `env` in `~/.claude/settings.json` and need extension version 2.1.307 or later; only that file or the environment VS Code started with reaches them, and the environment wins.

For a `claude` on your own Node, set `NODE_EXTRA_CA_CERTS` or `NODE_USE_SYSTEM_CA=1` (added in v22.19.0 and v24.6.0); an npm install reads the OS store only on Node 22.15 or later. Leave `NODE_OPTIONS=--use-system-ca` out: a maintainer confirmed on [issue #72066](https://github.com/anthropics/claude-code/issues/72066) that Claude Code then drops its bundled roots and keeps only the OS store, and the changelog records no fix as of 24 October 2026, with the regression last reproduced on 2.1.252. See [VS Code and Cursor](https://pkizerotohero.com/errors/vscode-self-signed-certificate-in-certificate-chain/).

### The settings file or a Desktop subprocess did not pass the variable on

Reported, never documented: the `env` block’s `NODE_EXTRA_CA_CERTS` had no effect while `/status` showed it set (#22512); WebFetch ignored it behind Zscaler until `NODE_USE_SYSTEM_CA=1` (#25977); Claude Desktop’s Code tab passed only `PATH` to its CLI child (#22559). If the log shows nothing loaded, export it in your shell instead. Since v2.1.217 a Desktop session the app connects for reads them from managed settings and `~/.claude/settings.json` only: use the user file.

An MCP stdio server is a child process; its `env` block, or `--env NODE_EXTRA_CA_CERTS=/path/ca.pem` on `claude mcp add`, is the documented way to hand it variables, and a shell export is not guaranteed to reach it. Other languages need their own variable: [MCP servers behind a corporate proxy](https://pkizerotohero.com/guides/mcp-server-certificate-errors/).

### WSL, Docker or a dev container cannot see the Windows store

Linux inside WSL or a container cannot see the host’s store, so copy the exported root in and install it:

```bash
sudo cp /mnt/c/certs/proxy-root.pem /usr/local/share/ca-certificates/proxy-root.crt
sudo update-ca-certificates
```

In a dev container, `COPY` the file in the Dockerfile, set `NODE_EXTRA_CA_CERTS` in `containerEnv` and edit `~/.claude/settings.json` on the remote system: the laptop’s copy is never read there. [Docker x509 unknown authority](https://pkizerotohero.com/errors/docker-x509-unknown-authority/) covers the daemon’s own pulls.

### The installer’s second step fetches with the new binary

The script’s download uses the OS store and succeeds; `claude install` then fetches the release version from `downloads.claude.ai` (or storage.googleapis.com on versions before 2.1.116) with the binary’s own client, the step issue #22756 shows failing. Install the root in the OS store first, or use a package (apt, dnf, apk, Homebrew, WinGet) the proxy lets through.

Warning

Why NODE\_TLS\_REJECT\_UNAUTHORIZED=0 is a trap

It switches verification off for every connection, so Claude Code completes the handshake with anything answering on port 443 and sends it your API key or OAuth token, your prompts and your source: the exact [man-in-the-middle](https://pkizerotohero.com/handbook/glossary/#man-in-the-middle) condition the check exists to catch. The docs say not to set it, Node calls it strongly discouraged, and cloud sessions ignore it from a settings file. Fix the store instead.

## Check yours

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

Paste every certificate from `openssl s_client -showcerts`; the checker names the root and flags known HTTPS-inspection products.

## Learn why

- [Trust stores](https://pkizerotohero.com/handbook/trust-stores/) and [certificate chains](https://pkizerotohero.com/handbook/certificate-chains/).
- Related: [Node.js SELF\_SIGNED\_CERT\_IN\_CHAIN](https://pkizerotohero.com/errors/node-self-signed-cert-in-chain/), [corporate proxies](https://pkizerotohero.com/guides/corporate-proxy-certificates/), [Python, Node.js and npm](https://pkizerotohero.com/guides/trust-ca-python-node/) and [MCP servers](https://pkizerotohero.com/guides/mcp-server-certificate-errors/).
- Claude Code: [network configuration](https://code.claude.com/docs/en/network-config), [SSL certificate errors](https://code.claude.com/docs/en/errors#ssl-certificate-errors), [the VS Code extension](https://code.claude.com/docs/en/vs-code#dictation-or-the-web-tab-fails-behind-a-tls-inspecting-proxy), [troubleshoot installation](https://code.claude.com/docs/en/troubleshoot-install#tls-or-ssl-connection-errors) and the [changelog](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md).

**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=/errors/claude-code-self-signed-cert-in-chain/).

Last reviewed 24 October 2026Edition 0.9

## Learn why it happens

- [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/)

## Everything on this topic

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