Fix Python 'CERTIFICATE_VERIFY_FAILED' & Docker 'x509: certificate signed by unknown authority' on Mac

Fix Python, pip, uv, requests [SSL: CERTIFICATE_VERIFY_FAILED] and Docker Desktop x509: certificate signed by unknown authority errors behind Zscaler, Netskope, Cloudflare, or corporate SWGs on macOS.

SWG bar · Updated

On a corporate MacBook behind an SSL-inspecting Secure Web Gateway (Zscaler, Cloudflare WARP, Netskope, Cisco Umbrella, Palo Alto, or Fortinet), Python (pip, uv, requests, conda) frequently fails with ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] unable to get local issuer certificate, and Docker Desktop fails during docker pull or docker build with x509: certificate signed by unknown authority.

Both errors happen for the same reason: macOS System Keychain trusts your company’s MDM-installed SWG root CA, but Python’s certifi bundle and Docker Desktop’s Linux VM maintain isolated certificate stores. Paste your raw error into our free SWG & SSL Error Decoder or apply the exact fixes below.

1. Export your corporate SWG Root CA PEM on macOS

First identify the intercepting CA via SWG bar → Certificates or openssl s_client -connect pypi.org:443 -servername pypi.org </dev/null 2>/dev/null | openssl x509 -noout -issuer, then export it cleanly to ~/.certs/corporate-swg-root.pem:

mkdir -p "$HOME/.certs"
# Replace "Zscaler" with Cloudflare, goskope, Cisco Umbrella, Fortinet, or your corporate CA name
security find-certificate -c "Zscaler" -p /Library/Keychains/System.keychain > "$HOME/.certs/corporate-swg-root.pem"

(Note: For Python requests / pip, append the corporate root to a combined bundle alongside certifi or use native OS trust so public roots keep working alongside your corporate CA.)

2. Fix Python, pip, uv & requests (CERTIFICATE_VERIFY_FAILED)

Fastest modern fix (uses macOS System Keychain directly)

  • For uv (Astral):
    export UV_NATIVE_TLS=true
  • For pip 24.2+:
    pip config set global.use-feature truststore
  • For Python requests / httpx / urllib (append corporate root to certifi):
    CERTIFI_CA=$(python3 -c "import certifi; print(certifi.where())")
    cat "$CERTIFI_CA" "$HOME/.certs/corporate-swg-root.pem" > "$HOME/.certs/python-combined-ca.pem"
    echo 'export SSL_CERT_FILE="$HOME/.certs/python-combined-ca.pem"' >> ~/.zshrc
    echo 'export REQUESTS_CA_BUNDLE="$HOME/.certs/python-combined-ca.pem"' >> ~/.zshrc
    source ~/.zshrc

3. Fix Docker Desktop (x509: certificate signed by unknown authority)

Docker fails in two separate places on macOS—fixing only one leaves the other broken:

  1. Docker daemon (docker pull / docker login): Docker Desktop on macOS automatically syncs trusted roots from System Keychain when it starts. If your company pushed a new SWG certificate while Docker was open, fully quit and restart Docker Desktop (or verify under Keychain Access that the root CA is set to Always Trust). For Colima or OrbStack, copy corporate-swg-root.pem into the Linux VM’s /usr/local/share/ca-certificates/ and run update-ca-certificates.
  2. Inside docker build containers (apt-get, pip, npm, curl inside builds): Containers do not inherit macOS Keychain. Pass your corporate CA as a build secret or copy it during build:
COPY corporate-swg-root.pem /usr/local/share/ca-certificates/corporate-swg.crt
RUN update-ca-certificates

4. Skip CA bundle maintenance: per-domain SWG bypass on Mac

If you work on an authorized network where per-domain bypass is permitted, SWG bar lets you confirm exactly which registries (pypi.org, files.pythonhosted.org, registry-1.docker.io, auth.docker.io) are being decrypted and bypass them per hostname in one click—eliminating container and virtualenv CA mismatches altogether:

swgbar probe pypi.org
swgbar bypass enable pypi.org
swgbar bypass enable files.pythonhosted.org

See How to bypass SWG on a Mac and Configure CA trust for Homebrew, Docker, Python, and Node.js for complete details.