Fix AWS CLI & Boto3 'SSL validation failed' Certificate Errors on Mac

Fix AWS CLI v2, Boto3, AWS SAM, and CDK SSL validation failed / CERTIFICATE_VERIFY_FAILED errors behind Zscaler, Cloudflare WARP, or Netskope on macOS—filling the macOS gap in official SWG docs.

SWG bar · Updated

When running aws s3 ls, aws sts get-caller-identity, aws sso login, or Python Boto3 scripts on a corporate Mac behind Zscaler, Cloudflare WARP, Netskope, Cisco Umbrella, or Palo Alto GlobalProtect, you will often hit:

SSL validation failed for https://sts.us-east-1.amazonaws.com/
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:
unable to get local issuer certificate (_ssl.c:1006)

Official SWG help docs frequently document only Windows or Ubuntu paths for AWS CLI and Boto3. Even worse, setting AWS_CA_BUNDLE to only your corporate SWG root certificate causes another trap: AWS CLI v2 and botocore replace their entire default truststore when AWS_CA_BUNDLE is set, so any non-intercepted AWS endpoint immediately breaks. Paste your error into our free SWG & SSL Error Decoder or follow the upgrade-safe macOS fix below.

1. Build a combined macOS + corporate SWG CA bundle

Instead of overwriting Homebrew’s or /usr/local/aws-cli’s internal cacert.pem (which gets wiped on every upgrade), build a single combined PEM file in ~/.certs/aws-combined-ca.pem that contains all macOS system root CAs plus your corporate SWG root CA:

mkdir -p "$HOME/.certs"

# 1. Export Apple's built-in trusted public root CAs
security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain > "$HOME/.certs/aws-combined-ca.pem"

# 2. Append your corporate SWG Root CA (replace "Zscaler" with Cloudflare, goskope, Cisco Umbrella, Fortinet, etc.)
security find-certificate -c "Zscaler" -p /Library/Keychains/System.keychain >> "$HOME/.certs/aws-combined-ca.pem"

Because both standard public roots (including Amazon Root CA 1–4) and your corporate SWG CA are inside one bundle, both inspected and non-inspected AWS endpoints validate cleanly.

2. Configure AWS CLI v2 persistently on macOS

Set the ca_bundle option in ~/.aws/config so every terminal session, IDE task, and script picks it up automatically:

aws configure set default.ca_bundle "$HOME/.certs/aws-combined-ca.pem"

If you use multiple named AWS profiles (--profile prod), also export AWS_CA_BUNDLE in ~/.zshrc so every profile inherits it automatically:

echo 'export AWS_CA_BUNDLE="$HOME/.certs/aws-combined-ca.pem"' >> ~/.zshrc
source ~/.zshrc

Verify without ever using --no-verify-ssl:

aws sts get-caller-identity

3. Fix Python Boto3, AWS SAM CLI & AWS CDK on macOS

Different AWS tools use different runtimes underneath:

  • Python boto3 & botocore: Automatically respect AWS_CA_BUNDLE (as well as REQUESTS_CA_BUNDLE). For scripts that also call non-AWS HTTPS APIs via requests, add to ~/.zshrc:
    export AWS_CA_BUNDLE="$HOME/.certs/aws-combined-ca.pem"
    export REQUESTS_CA_BUNDLE="$HOME/.certs/aws-combined-ca.pem"
    export SSL_CERT_FILE="$HOME/.certs/aws-combined-ca.pem"
  • AWS SAM CLI (sam build / sam deploy): Respects AWS_CA_BUNDLE. If sam build --use-container fails inside Docker, also follow our Docker Desktop x509 certificate fix for Mac.
  • AWS CDK (cdk synth / cdk deploy): Runs on Node.js, which ignores AWS_CA_BUNDLE and requires NODE_EXTRA_CA_CERTS pointing to your corporate SWG root PEM:
    security find-certificate -c "Zscaler" -p /Library/Keychains/System.keychain > "$HOME/.certs/corporate-swg-root.pem"
    echo 'export NODE_EXTRA_CA_CERTS="$HOME/.certs/corporate-swg-root.pem"' >> ~/.zshrc
    source ~/.zshrc

4. Skip CA bundle maintenance with per-domain SWG bypass

If your organization allows per-domain SWG bypass for cloud control-plane APIs, SWG bar confirms which AWS endpoints are being decrypted and restores the authentic Amazon TLS certificate per hostname in one click—keeping your corporate VPN and SSO untouched:

swgbar probe sts.amazonaws.com
swgbar bypass enable sts.amazonaws.com
swgbar bypass enable s3.amazonaws.com

Also using GCP or Azure on the same Mac? Read Fix Google Cloud (gcloud) & Azure CLI (az login) SSL errors on Mac, Fix Python & Docker SSL errors on Mac, and How to bypass SWG on a Mac.