Skip to content

claude-code: CLAUDE_CODE_CERT_STORE=system breaks TLS on darwin (UNABLE_TO_GET_ISSUER_CERT_LOCALLY) #579204

Closed

Description

@mchataigner

Describe the bug

Since #576509, the claude-code wrapper sets
--set-default CLAUDE_CODE_CERT_STORE system. On aarch64-darwin every request
then fails:

API Error: Unable to connect to API: SSL certificate verification failed (UNABLE_TO_GET_ISSUER_CERT_LOCALLY).

The PR describes the system store as "SSL_CERT_FILE or /etc/ssl/certs", which is
how it works on Linux. On macOS, Bun (which claude-code is compiled with) reads
the keychain for its system store, not those files. It returns only the
certificates that are explicitly trusted in the keychain search list, and that
list leaves out Apple's built-in roots (in
/System/Library/Keychains/SystemRootCertificates.keychain). Unless the user
has added public roots to a keychain themselves, nothing on the public web
verifies.

claude --debug shows it:

CA certs: stores=system, extraCertsPath=undefined
CA certs: Loaded 1 system CA certificates

On my machine the one certificate is Apple's "Developer ID Certification
Authority" intermediate from the login keychain.

Steps to reproduce

On aarch64-darwin with claude-code 2.1.309 (Bun v1.4.4):

  1. claude -p 'reply ok' fails with the error above.
  2. CLAUDE_CODE_CERT_STORE=bundled claude -p 'reply ok' and
    CLAUDE_CODE_CERT_STORE=bundled,system claude -p 'reply ok' both work.
  3. SSL_CERT_FILE has no effect: pointing it at the full cacert bundle, at a
    file that holds only the needed root (GTS Root R4), or at a nonexistent path
    all still give "Loaded 1 system CA certificates".

The runtimes agree, so this is not specific to claude-code:

nix shell nixpkgs#bun nixpkgs#nodejs -c sh -c '
  bun  -e "console.log(require(\"tls\").getCACertificates(\"system\").length)"
  node -e "console.log(require(\"tls\").getCACertificates(\"system\").length)"'
# 1
# 1

(Bun 1.4.2 and Node 24.21.0 from nixpkgs; the same result outside any sandbox.)

The network is fine: openssl s_client and curl verify api.anthropic.com
against the usual Google Trust Services chain.

Expected behaviour

claude-code connects out of the box on darwin, as it did before #576509.

Suggested fix

Set the default only on Linux, where "system" means the cacert bundle:

${lib.optionalString stdenv.hostPlatform.isLinux ''
  --set-default CLAUDE_CODE_CERT_STORE system \
''}

or use bundled,system on darwin, which keeps the bundled roots while still
honouring CAs added to the keychain.

Workaround

Run with CLAUDE_CODE_CERT_STORE=bundled,system (the wrapper uses
--set-default, so the environment wins), or override the package so its
installPhase sets that value.

Metadata

  • system: aarch64-darwin
  • nixpkgs: nixpkgs-unstable, claude-code 2.1.309
  • Built on: aarch64-darwin (macOS 27.0)

Activity

  1. booxter commented on Oct 26, 2026

    @booxter
    Contributor

    I don't think we should regress to bundled certs. We can teach the claude wrapper to honor NIX_SSL_CERT_FILE. E.g.:

    wrapProgramShell "$out/bin/claude" --run ${lib.escapeShellArg ''
      if [ -z "''${NODE_EXTRA_CA_CERTS:-}" ] && [ -n "''${NIX_SSL_CERT_FILE:-}" ]; then
        export NODE_EXTRA_CA_CERTS="$NIX_SSL_CERT_FILE"
      fi
    ''
    
  2. svenjacobs commented on Oct 27, 2026

    @svenjacobs
    Contributor

    Same on my aarch64-darwin machine (MDM-managed Mac, Determinate Nix, standalone Home Manager) with claude-code 2.1.309, since an update that brought in #576509. Every API request fails with UNABLE_TO_GET_ISSUER_CERT_LOCALLY. CLAUDE_CODE_CERT_STORE=bundled,system fixes it. I set it in home.sessionVariables for now.

  3. adamcstephens commented on Oct 27, 2026

    @adamcstephens
    Contributor
    1. I don't think we should regress to bundled certs. We can teach the claude wrapper to honor NIX_SSL_CERT_FILE. E.g.:
      wrapProgramShell "$out/bin/claude" --run ${lib.escapeShellArg '' if [ -z "''${NODE_EXTRA_CA_CERTS:-}" ] && [ -n "''${NIX_SSL_CERT_FILE:-}" ]; then export NODE_EXTRA_CA_CERTS="$NIX_SSL_CERT_FILE" fi ''

    This doesn't work with makeBinaryWrapper. I've used what it resolves to instead in #579756

  4. seh commented on Oct 27, 2026

    @seh

    If you use the claude agents subcommand, be sure to find its daemon process and kill that one, then set the "CLAUDE_CODE_CERT_STORE" environment variable (such as to "bundled,system"), then invoke claude agents again, which will create a replacement daemon using the proper set of certificates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions