Fix GitHub Copilot, OpenAI Codex & Gemini CLI SSL Certificate Errors on Mac (Zscaler / SWG)
Fix unable to get local issuer certificate, UNABLE_TO_VERIFY_LEAF_SIGNATURE, and fetch failed errors in GitHub Copilot, OpenAI Codex CLI, and Gemini CLI behind corporate SWGs on macOS.
SWG bar · Updated
If GitHub Copilot (VS Code / JetBrains), OpenAI Codex CLI, or Gemini CLI fails on your work Mac with unable to get local issuer certificate, SELF_SIGNED_CERT_IN_CHAIN, UNABLE_TO_VERIFY_LEAF_SIGNATURE, or TypeError: fetch failed, your company’s Secure Web Gateway (Zscaler, Cloudflare WARP, Netskope, Cisco Umbrella, or Palo Alto Prisma Access) is decrypting HTTPS traffic to AI API endpoints (api.openai.com, generativelanguage.googleapis.com, api.githubcopilot.com, copilot-proxy.githubusercontent.com).
Paste your exact terminal or VS Code output into our free SWG & SSL Error Decoder, or follow the verified fixes below. (Using Claude Code or Cursor? Also see Fix Claude Code & Cursor certificate errors on macOS.)
1. Confirm which AI API hostnames are being intercepted
AI coding agents often hit separate auth, telemetry, and inference domains. Open SWG bar → Domains or probe the endpoints directly:
swgbar probe api.openai.com
swgbar probe generativelanguage.googleapis.com
swgbar probe api.githubcopilot.com
If any hostname reports Confirmed intercepted by Zscaler Root CA, Cloudflare Gateway CA, *.goskope.com, Cisco Umbrella, or a corporate Forward Trust CA, embedded Node.js/Rust runtimes inside those CLIs will reject the re-signed TLS chain.
2. Option A (Fastest): Per-domain SWG bypass + native MCP control
On authorized networks, bypassing just the AI API domains with SWG bar immediately restores streaming SSE/WebSocket responses without weakening TLS security or touching VPN/SSO:
swgbar bypass enable api.openai.com
swgbar bypass enable generativelanguage.googleapis.com
swgbar bypass enable api.githubcopilot.com
Restart your CLI session or reload the IDE window so pooled connections reopen directly over your Mac’s physical Hardware IPv4 interface. You can also connect Codex, Claude Code, Cursor, or Gemini CLI to SWG bar via local stdio MCP so your agent can inspect certificate evidence itself.
3. Option B: Trust your corporate SWG Root CA in Codex CLI, Gemini CLI & GitHub Copilot
When your organization requires AI traffic to stay routed through the corporate SWG, export your SWG Root CA PEM from System Keychain and configure each runtime cleanly—avoid NODE_TLS_REJECT_UNAUTHORIZED=0:
mkdir -p "$HOME/.certs"
# Replace "Zscaler" with Cloudflare, goskope, Cisco Umbrella, or your corporate CA name
security find-certificate -c "Zscaler" -p /Library/Keychains/System.keychain > "$HOME/.certs/corporate-swg-root.pem"
# Works for OpenAI Codex CLI, Gemini CLI, Node.js, and VS Code launched from Terminal
echo 'export NODE_EXTRA_CA_CERTS="$HOME/.certs/corporate-swg-root.pem"' >> ~/.zshrc
echo 'export SSL_CERT_FILE="$HOME/.certs/corporate-swg-root.pem"' >> ~/.zshrc
source ~/.zshrc
App-specific macOS gotchas
- GitHub Copilot in VS Code / Cursor (Dock launch trap): GUI apps launched from the macOS Dock do not read
~/.zshrc. Either launch VS Code from Terminal (code .), set"http.systemCertificates": truein VS Code Settings, or use the official macOS System Keychain trust mode (NODE_EXTRA_CA_CERTSvialaunchctl setenv). - OpenAI Codex CLI (Rust / reqwest + Node wrapper): Setting both
SSL_CERT_FILEandNODE_EXTRA_CA_CERTScovers both OpenSSL/Rust binaries and Node.js sub-processes. - Gemini CLI (
generativelanguage.googleapis.com& OAuth): Authentication also contactsoauth2.googleapis.comandaccounts.google.com—make sure all three hostnames are covered if using multi-domain SSO, API, and CDN bypass. - SSE streaming hangs behind SWGs: Even when the CA is trusted, some SWGs buffer Server-Sent Events (SSE) until timeout—per-domain bypass or an IT
Do Not Inspectexclusion for the inference domain resolves stuck streaming responses.