Skip to content
AI Dev Toolkit.
Esc
  • Loading…

Claude Code · Certificates and network

Self-signed certificate detected (SELF_SIGNED_CERT_IN_CHAIN)

Fix SELF_SIGNED_CERT_IN_CHAIN and “Self-signed certificate detected” in Claude Code and WSL: trust your proxy or antivirus root safely, step by step.

Message

The exact error

Claude Code
Unable to connect to API: Self-signed certificate detected (SELF_SIGNED_CERT_IN_CHAIN). The certificate comes from an authority Claude Code doesn't trust, usually a TLS-inspecting corporate proxy or a gateway signed by a private CA: set NODE_EXTRA_CA_CERTS to that CA bundle, or add it to the system certificate store · see https://code.claude.com/docs/en/network-config

Also appears as:

During /login or the startup check
SSL certificate error (SELF_SIGNED_CERT_IN_CHAIN). If you are behind a corporate proxy or TLS-intercepting firewall, set NODE_EXTRA_CA_CERTS to your CA bundle path, or ask IT to allowlist *.anthropic.com. Run `claude doctor` for details.
Before v2.1.273
Unable to connect to API: Self-signed certificate detected. Check your proxy or corporate SSL certificates
Related code with the same message
DEPTH_ZERO_SELF_SIGNED_CERT (the server’s own certificate is self-signed)

Meaning

What does SELF_SIGNED_CERT_IN_CHAIN mean?

Every certificate chain ends in a root that signs itself. Public roots are trusted because they ship with operating systems and Claude Code. When the root at the end of the chain isn’t one of those, Claude Code reports a self-signed certificate. In practice it means something between you and Anthropic presented its own certificate, typically a company proxy that inspects HTTPS, or a gateway using an internal certificate authority. The related DEPTH_ZERO_SELF_SIGNED_CERT is narrower: the server’s own certificate signs itself, with no chain at all, which usually means an internal gateway set up with a self-signed certificate that its operator should replace.

Causes

What causes it?

  • TLS inspection by a corporate proxy, antivirus web shield or firewall
  • An internal LLM gateway (set with ANTHROPIC_BASE_URL) using a certificate from a private CA
  • Antivirus “HTTPS scanning” on a personal computer, which installs its own root
  • A local debugging proxy such as Charles, Fiddler or mitmproxy left running, which re-signs HTTPS with its own root
  • In WSL, a company root that IT installed in Windows but not inside the Linux distro

Fix

How do I fix SELF_SIGNED_CERT_IN_CHAIN?

  1. Find out which certificate authority is intercepting

    Open https://api.anthropic.com in your browser and click the padlock, then view the certificate chain. If the top of the chain is your company’s or a security product’s root (names like Zscaler, Netskope, Palo Alto, Fortinet or your company name) rather than a public authority, a TLS-inspecting proxy is in the path. That root is the certificate Claude Code needs to trust. Your IT team can also give you the file directly.

  2. On a personal computer, check your antivirus

    Products with HTTPS or web scanning add their own root certificate. Either export that root as below, or turn off HTTPS scanning for *.anthropic.com in the antivirus settings.

  3. Export that root certificate as a PEM file

    NODE_EXTRA_CA_CERTS needs PEM text, the kind that starts with -----BEGIN CERTIFICATE-----. A binary .cer (DER) file doesn’t work, and Node gives no warning about it.

    Windows (PowerShell): export from the certificate store and convert to PEM
    $cert = Get-ChildItem Cert:\LocalMachine\Root | Where-Object Subject -like "*Your Proxy CA*" | Select-Object -First 1
    New-Item -ItemType Directory -Force C:\certs | Out-Null
    Export-Certificate -Cert $cert -FilePath C:\certs\corp-ca.cer -Type CERT
    certutil -encode C:\certs\corp-ca.cer C:\certs\corp-ca.pem
    macOS: export from the System keychain as PEM
    security find-certificate -a -c "Your Proxy CA" -p /Library/Keychains/System.keychain > ~/corp-ca.pem
    Linux: the system bundle already includes CAs your admin installed
    # Debian/Ubuntu
    ls /etc/ssl/certs/ca-certificates.crt
    # RHEL/Fedora
    ls /etc/pki/tls/certs/ca-bundle.crt
  4. Point Claude Code at the file, then restart it

    Claude Code reads these variables once at startup, so restart it after setting them. Putting the variable in the env block of ~/.claude/settings.json makes it apply to every session, including background agents that don’t inherit your shell.

    macOS / Linux
    export NODE_EXTRA_CA_CERTS=~/corp-ca.pem
    claude
    Windows PowerShell
    $env:NODE_EXTRA_CA_CERTS = 'C:\certs\corp-ca.pem'
    claude
    Or permanently, in ~/.claude/settings.json
    {
      "env": {
        "NODE_EXTRA_CA_CERTS": "/path/to/corp-ca.pem"
      }
    }
  5. In WSL, add the root inside the distro too

    On Debian or Ubuntu, copy the PEM file into the distro’s store with a .crt name and rebuild the bundle, then open a new WSL shell. This example uses the C:\certs\corp-ca.pem file from the Windows export above.

    WSL (Debian / Ubuntu)
    sudo cp /mnt/c/certs/corp-ca.pem /usr/local/share/ca-certificates/corp-ca.crt
    sudo update-ca-certificates
  6. Confirm the certificate loaded

    Start a session with claude --debug and look in the debug log (in ~/.claude/debug/) for CA certs: Appended extra certificates from NODE_EXTRA_CA_CERTS. A Failed to read line means the path is wrong. In plain Node, a missing file shows Warning: Ignoring extra certs from …, load failed on the first secure connection.

Don’t do this

  • Don’t set NODE_TLS_REJECT_UNAUTHORIZED=0. It switches off certificate checking entirely, so any machine on the network could read or change your traffic, including your API key.

Explained

How do I fix it in WSL?

WSL runs a separate Linux system with its own certificate store, so a root that IT installed in Windows isn’t trusted inside the distro. Export the root as PEM on the Windows side (steps above), then add it to the distro’s store from a WSL shell. Claude Code’s native installer reads the system store, so that is usually enough; pointing NODE_EXTRA_CA_CERTS at the same file inside WSL also works. Open a new WSL shell before starting claude.

Explained

Why do I see it with no proxy configured?

If you aren’t on a company network, look for software on your own machine that inspects HTTPS: antivirus web shields, parental-control filters, ad blockers that install a root, or a debugging proxy such as Charles, Fiddler or mitmproxy left running. Quit it, or exclude *.anthropic.com from its scanning, then retry. The certificate chain in your browser’s padlock view names the product. If the certificate is for the wrong hostname rather than from an unknown issuer, see SSL hostname mismatch; during install, the same proxy causes curl (60).

FAQ

Questions people ask

Why does npm work but Claude Code shows SELF_SIGNED_CERT_IN_CHAIN?

npm has its own cafile setting, which your company may have set for you, while Claude Code reads its bundled certificates, the system store and NODE_EXTRA_CA_CERTS. Run npm config get cafile to find the file npm uses, point NODE_EXTRA_CA_CERTS at the same PEM file, then restart Claude Code.

Why does WSL show the error when Windows works?

WSL is a separate Linux system with its own certificate store, so a root that IT installed in Windows isn’t in the WSL distro. Export the root as PEM, copy it into the distro, add it with update-ca-certificates or point NODE_EXTRA_CA_CERTS at it inside WSL, and start Claude Code from a new WSL shell.

What is the difference between SELF_SIGNED_CERT_IN_CHAIN and DEPTH_ZERO_SELF_SIGNED_CERT?

SELF_SIGNED_CERT_IN_CHAIN means the chain ends in a self-signed root that isn’t trusted, usually a proxy’s or private CA’s root that you can add. DEPTH_ZERO_SELF_SIGNED_CERT means the server’s own certificate is self-signed and isn’t in the trusted list, typically an internal gateway. Its operator should issue a proper certificate.

Related

Search all Claude Code errors

Keep exploring