Fix Git & npm 'unable to get local issuer certificate' / SELF_SIGNED_CERT_IN_CHAIN on Mac

Fix Git SSL certificate problem: unable to get local issuer certificate and npm/Node SELF_SIGNED_CERT_IN_CHAIN or UNABLE_TO_VERIFY_LEAF_SIGNATURE behind Zscaler, Cloudflare, Netskope, or corporate SWGs on macOS.

SWG bar · Updated

When Git fails on your Mac with SSL certificate problem: unable to get local issuer certificate (or self signed certificate in certificate chain) and npm / Node.js / pnpm / Yarn fails with SELF_SIGNED_CERT_IN_CHAIN or UNABLE_TO_VERIFY_LEAF_SIGNATURE, the cause on a work Mac is almost always corporate SWG HTTPS inspection (Zscaler, Cloudflare WARP, Netskope, Cisco Umbrella, Palo Alto, or Fortinet).

Safari and Chrome work because MDM installs the corporate SWG root certificate into macOS System Keychain—while Node.js and OpenSSL-backed Git rely on separate CA bundles. Paste your exact error into our free SWG & SSL Error Decoder for auto-generated commands, or follow the two safe fixes below.

1. Confirm which corporate CA is intercepting GitHub or npm

Run a quick check in Terminal—or open SWG bar → Certificates—to identify the exact root CA name installed by your company:

openssl s_client -connect registry.npmjs.org:443 -servername registry.npmjs.org </dev/null 2>/dev/null | openssl x509 -noout -issuer
openssl s_client -connect github.com:443 -servername github.com </dev/null 2>/dev/null | openssl x509 -noout -issuer

If issuer= shows Zscaler, Cloudflare, Netskope (*.goskope.com), Cisco Umbrella, Fortinet_CA_SSL, or your company name instead of a public CA (DigiCert, Google Trust Services, Let’s Encrypt), SSL inspection is intercepting your packages.

2. Option A (Fastest): Bypass SWG per domain with SWG bar

If you are on an authorized network and want Git, npm, pnpm, and Node.js to see the genuine origin certificate without maintaining .pem files across every tool:

  1. Install SWG bar (macOS 14+ Apple silicon, 14-use-day free trial).
  2. Enable per-domain bypass for the exact registry or Git host:
swgbar bypass enable github.com
swgbar bypass enable registry.npmjs.org
  1. Re-run git pull or npm install. See How to bypass SWG on a Mac for full setup details.

3. Option B: Trust your exported corporate Root CA in Git, Node.js, npm, pnpm & Yarn

When corporate policy requires traffic to stay decrypted, export your SWG Root CA PEM from macOS System Keychain (replace Zscaler with your issuer from Step 1) and configure Git and Node cleanly—never disable TLS globally with git config http.sslVerify false or NODE_TLS_REJECT_UNAUTHORIZED=0:

mkdir -p "$HOME/.certs"
security find-certificate -c "Zscaler" -p /Library/Keychains/System.keychain > "$HOME/.certs/corporate-swg-root.pem"

# 1. Fix Git (HTTPS clones, fetches, submodules)
git config --global http.sslCAInfo "$HOME/.certs/corporate-swg-root.pem"

# 2. Fix Node.js, npm, pnpm, Yarn, Vite, Claude Code & Cursor
echo 'export NODE_EXTRA_CA_CERTS="$HOME/.certs/corporate-swg-root.pem"' >> ~/.zshrc
source ~/.zshrc

Tool-specific notes on macOS

  • Git on macOS (Apple Git vs Homebrew Git): Apple’s built-in Git supports git config --global http.sslBackend secure-transport (which reads macOS Keychain directly), whereas Homebrew Git uses OpenSSL and requires http.sslCAInfo.
  • Node.js 22+ (--use-system-ca): Newer Node.js builds support NODE_OPTIONS="--use-system-ca", though NODE_EXTRA_CA_CERTS remains the most compatible setting across Node 18/20/22, npm, pnpm, and yarn.
  • npm / pnpm / Yarn strict SSL: Keep strict-ssl=true. NODE_EXTRA_CA_CERTS appends your corporate root CA on top of Node’s built-in roots so both internal registries and public npm packages verify safely.

Also seeing errors in Python, Docker, or AI coding tools? Read Fix Python CERTIFICATE_VERIFY_FAILED & Docker x509 on Mac and Fix GitHub Copilot, OpenAI Codex & Gemini CLI SSL errors.