Repository navigation
Description
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):
claude -p 'reply ok'fails with the error above.CLAUDE_CODE_CERT_STORE=bundled claude -p 'reply ok'and
CLAUDE_CODE_CERT_STORE=bundled,system claude -p 'reply ok'both work.SSL_CERT_FILEhas 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
booxter commentedon Oct 26, 2026
I don't think we should regress to bundled certs. We can teach the claude wrapper to honor
NIX_SSL_CERT_FILE. E.g.:svenjacobs commentedon Oct 27, 2026
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,systemfixes it. I set it inhome.sessionVariablesfor now.adamcstephens commentedon Oct 27, 2026
This doesn't work with
makeBinaryWrapper. I've used what it resolves to instead in #579756seh commentedon Oct 27, 2026
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.
temp fix for claude cert issue NixOS/nixpkgs#579204
darwin cert fix (NixOS/nixpkgs#579204)
darwin cert fix (NixOS/nixpkgs#579204)