---
title: "Fix Terraform, OpenTofu, Ansible & Packer x509 SSL Errors on Mac — SWG bar"
description: "Fix Terraform, OpenTofu, Ansible & Packer x509 unknown authority and SSL verify failed errors behind Zscaler, Cloudflare WARP, or Netskope on macOS safely."
image: "https://swgbar.com/brand/swgbar-og-1200x630.png"
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://swgbar.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

Source: https://swgbar.com/en/guides/fix-terraform-ansible-packer-x509-ssl-error-mac/
Language: en

# Fix Terraform, OpenTofu, Ansible & Packer x509 SSL Errors on Mac

Fix Terraform, OpenTofu, Ansible & Packer x509 unknown authority and SSL verify failed errors behind Zscaler, Cloudflare WARP, or Netskope on macOS safely.

SWG bar · Updated December 5, 2026

When running `terraform init`, `tofu init`, `ansible-galaxy collection install`, `ansible-playbook`, or `packer init` on a work Mac behind Zscaler, Cloudflare WARP, Netskope, Cisco Umbrella, Palo Alto GlobalProtect, or Fortinet, TLS verification frequently aborts with errors like:

```
# Terraform / OpenTofu (provider registry & remote backend)
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider hashicorp/aws:
could not connect to registry.terraform.io: failed to request discovery document:
Get "https://registry.terraform.io/.well-known/terraform.json":
tls: failed to verify certificate: x509: certificate signed by unknown authority

# Ansible Galaxy & Python-based modules (urllib / requests / botocore)
ERROR! Error when finding available api versions from default (https://galaxy.ansible.com/api/)
(<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:
unable to get local issuer certificate (_ssl.c:1000)>)

# Packer (packer init / plugin downloads & cloud builders)
Error: Failed to initialize plugin "github.com/hashicorp/amazon"
Get "https://api.github.com/repos/hashicorp/packer-plugin-amazon/releases":
tls: failed to verify certificate: x509: certificate signed by unknown authority
```

Paste your raw terminal output into the free [SWG & SSL Error Decoder](<https://swgbar.com/en/tools/tls-error-decoder/>) to pinpoint the failing TLS stack, or apply the upgrade-safe macOS trust-store fix below.

## 1\. Why Terraform, OpenTofu, Ansible & Packer reject corporate SWG certificates

Browsers like Safari and Chrome validate TLS chains through macOS System Keychain, where MDM installs your organization’s SWG Root CA. Infrastructure-as-Code (IaC) toolchains span **two separate TLS runtimes plus child processes**:

*   **Terraform, OpenTofu & Packer (Go `crypto/x509` + plugin subprocesses)**: All three binaries—and their provider/builder plugins (`terraform-provider-aws`, `terraform-provider-google`, `terraform-provider-azurerm`, `packer-plugin-amazon`)—are compiled in Go. On macOS, Go uses `Security.framework` only until `SSL_CERT_FILE` or `SSL_CERT_DIR` is set in your shell (which overrides Keychain completely, so a partial PEM file breaks every public CA), or until a cross-compiled/containerized binary or `git` subprocess (`git::https://...` modules) ignores macOS Keychain altogether.
*   **Ansible & `ansible-galaxy` (Python `ssl` + `requests`/`certifi` + cloud SDKs)**: Installed via Homebrew, `pipx`, or `uv`, Ansible runs on Python. `ansible-galaxy` and `ansible.builtin.uri` use Python’s `urllib`/`ssl` stack (`SSL_CERT_FILE`), while collections backed by `requests` or cloud SDKs (`botocore`, `google-auth`, `azure-core`) read `certifi`’s bundled `cacert.pem` (`REQUESTS_CA_BUNDLE`, `AWS_CA_BUNDLE`) and never consult macOS System Keychain.

Check which binaries and certificate environment variables are active first:

```
which -a terraform tofu packer ansible ansible-galaxy
env | grep -E 'SSL_CERT|REQUESTS_CA_BUNDLE|CURL_CA_BUNDLE|AWS_CA_BUNDLE|TF_CLI_CONFIG_FILE'
ansible --version
```

Never edit Homebrew’s or `certifi`’s `cacert.pem` in place: the next `brew upgrade` or `pipx upgrade ansible` silently overwrites your corporate CA. And never point `SSL_CERT_FILE` at _only_ your corporate SWG root certificate, or every non-inspected public HTTPS registry immediately breaks.

## 2\. Build an upgrade-safe combined macOS + corporate SWG CA bundle

Create a single PEM bundle in `~/.certs/iac-combined-ca.pem` containing **Apple’s built-in public root CAs plus your corporate SWG Root CA** so toolchain upgrades never wipe it:

```
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/iac-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/iac-combined-ca.pem"
```

Because both standard public roots and your corporate SWG root coexist in one user-owned file, inspected endpoints (`registry.terraform.io`, `registry.opentofu.org`, `galaxy.ansible.com`, `releases.hashicorp.com`, cloud provider APIs) and direct non-inspected endpoints all validate cleanly.

## 3\. Persist CA trust for Terraform, OpenTofu, Ansible, Packer & Git modules

Export the combined bundle across all four CA environment variables in `~/.zshrc`:

```
cat <<'EOF' >> ~/.zshrc
export SSL_CERT_FILE="$HOME/.certs/iac-combined-ca.pem"
export REQUESTS_CA_BUNDLE="$HOME/.certs/iac-combined-ca.pem"
export CURL_CA_BUNDLE="$HOME/.certs/iac-combined-ca.pem"
export AWS_CA_BUNDLE="$HOME/.certs/iac-combined-ca.pem"
export TF_PLUGIN_CACHE_DIR="$HOME/.terraform.d/plugin-cache"
EOF
mkdir -p "$HOME/.terraform.d/plugin-cache"
source ~/.zshrc
```

Each variable covers a distinct IaC layer:

*   **`SSL_CERT_FILE`**: Go’s `crypto/x509` (Terraform, OpenTofu, Packer, and gRPC provider/plugin subprocesses) plus Python’s `urllib`/`ssl` (`ansible-galaxy` and `ansible.builtin.uri`).
*   **`REQUESTS_CA_BUNDLE`**: Python `requests`\-based Ansible collections and dynamic inventory plugins.
*   **`AWS_CA_BUNDLE` & `CURL_CA_BUNDLE`**: `terraform-provider-aws`, Packer’s Amazon builder, `amazon.aws` Ansible collection (`botocore`), and `libcurl`\-based provisioner scripts.
*   **`TF_PLUGIN_CACHE_DIR`**: Caches downloaded Terraform/OpenTofu providers locally so subsequent workspaces avoid redundant registry fetches.

Also persist Git’s global CA bundle so remote Git-sourced Terraform/OpenTofu modules (`source = "git::https://..."`) and Ansible Galaxy Git dependencies verify cleanly:

```
git config --global http.sslCAInfo "$HOME/.certs/iac-combined-ca.pem"
```

Verify with full TLS verification enabled—**never** disable certificate validation (`ansible-galaxy ... --ignore-certs`, `validate_certs: false` in Ansible tasks, `insecure = true` / `skip_tls_verify = true` in Terraform/OpenTofu providers, `winrm_insecure = true` in Packer, `git config --global http.sslVerify false`, `curl -k`, or `NODE_TLS_REJECT_UNAUTHORIZED=0`):

```
python3 -c 'import urllib.request; print(urllib.request.urlopen("https://galaxy.ansible.com/api/").status)'
terraform init -upgrade   # or: tofu init -upgrade
packer init .
```

## 4\. Fix IDE runners, Packer guests & non-interactive shells

If `terraform`, `tofu`, `ansible-playbook`, or `packer` works in Terminal but fails inside **VS Code** (HashiCorp Terraform / Ansible extensions), **IntelliJ / PyCharm**, or GUI Git hooks, macOS GUI apps did not load `~/.zshrc`:

*   **Export the CA bundle for GUI apps in the current macOS login session**:
    
    ```
    launchctl setenv SSL_CERT_FILE "$HOME/.certs/iac-combined-ca.pem"
    launchctl setenv REQUESTS_CA_BUNDLE "$HOME/.certs/iac-combined-ca.pem"
    launchctl setenv CURL_CA_BUNDLE "$HOME/.certs/iac-combined-ca.pem"
    launchctl setenv AWS_CA_BUNDLE "$HOME/.certs/iac-combined-ca.pem"
    ```
    
    Quit and relaunch VS Code or PyCharm so background language servers and task runners pick up the new environment.
*   **Separate control-node TLS from guest VM/container TLS**: Setting `SSL_CERT_FILE` fixes TLS initiated from your Mac. If Packer or Ansible runs package downloads _inside_ a newly booted Linux VM or Docker container whose outbound traffic passes through your corporate SWG, install the corporate Root CA inside the guest OS trust store (`/usr/local/share/ca-certificates/` + `update-ca-certificates`) during provisioning.

## 5\. Avoid manual CA bundles with per-domain SWG bypass

IaC workflows talk to dozens of endpoints—provider registries, GitHub Releases, Ansible Galaxy, HCP Terraform, and cloud APIs—where strict provider validation, mTLS backends, or corporate intermediate CA rotations repeatedly break static PEM bundles. Where your company’s policy permits per-domain SWG bypass for developer registries and IaC endpoints, [SWG bar](<https://swgbar.com/en/install/>) identifies which domains are intercepted and restores the authentic TLS certificate per domain without disabling your corporate VPN or SSO (includes a 14 actual-use-day free trial):

```
swgbar probe registry.terraform.io
swgbar bypass enable registry.terraform.io
swgbar bypass enable registry.opentofu.org
swgbar bypass enable galaxy.ansible.com
swgbar bypass enable releases.hashicorp.com
```

Running cloud and cluster tooling on the same work Mac? Read [Fix `kubectl`, Helm & Minikube `x509` unknown authority on Mac](<https://swgbar.com/en/guides/fix-kubernetes-kubectl-helm-minikube-x509-mac/>), [Fix AWS CLI & Boto3 `SSL validation failed` on Mac](<https://swgbar.com/en/guides/fix-aws-cli-boto3-ssl-validation-failed-mac/>), and [How to bypass SWG on a Mac](<https://swgbar.com/en/guides/how-to-bypass-swg/>).

macOS 14+ · Apple Silicon

## Stop guessing which domains your company SWG decrypts.

SWG bar checks HTTPS inspection right from your Mac’s menu bar and lets you bypass broken domains in one click—while keeping corporate VPN and SSO running.

[Start a 14-day trial for $0](<https://swgbar.com/releases/2.4.13/SWGBar-macOS-arm64.pkg>) [Decode a TLS error](<https://swgbar.com/en/tools/tls-error-decoder/>) [Free Chrome extension](<https://chromewebstore.google.com/detail/bidclnlfneemkkdeanlcbpjfdalelmbf>)

## Keep reading

*   [How to Bypass SWG on a Mac (1-Click & CLI Guide)](<https://swgbar.com/en/guides/how-to-bypass-swg/>)
*   [How to Bypass SSL Inspection on a Mac (Why Keychain & curl -k Fail)](<https://swgbar.com/en/guides/bypass-ssl-inspection-mac/>)
*   [HTTPS & TLS Break-and-Inspect on macOS: HTTP/2, QUIC & Per-Domain Bypass](<https://swgbar.com/en/guides/bypass-https-tls-inspection-mac/>)
*   [Why macOS Proxy Settings Fail Against Corporate Proxies (scutil & Per-Domain Fix)](<https://swgbar.com/en/guides/bypass-corporate-proxy-ssl-inspection-mac/>)
*   [How to Check if Your Mac Is Intercepted by an SWG (Zscaler, Netskope & SSL Inspection)](<https://swgbar.com/en/guides/detect-https-inspection/>)
*   [How to Check if Your Employer or Work Mac Is Intercepting HTTPS (SSL Inspection)](<https://swgbar.com/en/guides/check-if-work-mac-intercepting-https/>)
*   [Can My Employer See My Browsing History, Incognito & Personal Accounts on a Work Mac?](<https://swgbar.com/en/guides/can-employer-see-browsing-history-incognito-work-mac/>)
*   [SSL Inspection Checker for Mac: Menu Bar Tool to Detect HTTPS Interception](<https://swgbar.com/en/guides/ssl-inspection-checker-mac/>)
*   [Zscaler SSL Inspection on Mac: How to Check & Bypass per Domain](<https://swgbar.com/en/guides/zscaler-ssl-inspection-bypass-mac/>)
*   [How to Turn Off or Bypass Zscaler on a Mac (When Tamper Protection Locks It)](<https://swgbar.com/en/guides/disable-turn-off-zscaler-on-mac/>)
*   [Cloudflare WARP & Zero Trust TLS Inspection on Mac: Detect & Bypass](<https://swgbar.com/en/guides/cloudflare-warp-tls-inspection-mac/>)
*   [Netskope SSL Inspection on Mac: Check Decryption & Bypass per Domain](<https://swgbar.com/en/guides/netskope-ssl-inspection-bypass-mac/>)
*   [Cisco Umbrella SSL Inspection on Mac: Check Decryption & Bypass per Domain](<https://swgbar.com/en/guides/cisco-umbrella-ssl-inspection-bypass-mac/>)
*   [Palo Alto GlobalProtect & Prisma Access SSL Decryption on Mac: Check & Bypass](<https://swgbar.com/en/guides/palo-alto-globalprotect-prisma-ssl-decryption-mac/>)
*   [Fortinet FortiClient & FortiGate (Fortinet\_CA\_SSL) Inspection on Mac: Check & Bypass](<https://swgbar.com/en/guides/fortinet-forticlient-ssl-inspection-bypass-mac/>)
*   [Fix Git & npm 'unable to get local issuer certificate' / SELF\_SIGNED\_CERT\_IN\_CHAIN on Mac](<https://swgbar.com/en/guides/fix-git-npm-unable-to-get-local-issuer-certificate-mac/>)
*   [Fix Python 'CERTIFICATE\_VERIFY\_FAILED' & Docker 'x509: certificate signed by unknown authority' on Mac](<https://swgbar.com/en/guides/fix-python-docker-certificate-verify-failed-x509-mac/>)
*   [Fix GitHub Copilot, OpenAI Codex & Gemini CLI SSL Certificate Errors on Mac (Zscaler / SWG)](<https://swgbar.com/en/guides/fix-codex-copilot-gemini-cli-ssl-certificate-error-mac/>)
*   [Fix Java, Maven, Gradle, IntelliJ & Android Studio 'PKIX path building failed' on Mac](<https://swgbar.com/en/guides/fix-java-maven-gradle-intellij-android-studio-pkix-mac/>)
*   [Fix AWS CLI & Boto3 'SSL validation failed' Certificate Errors on Mac](<https://swgbar.com/en/guides/fix-aws-cli-boto3-ssl-validation-failed-mac/>)
*   [Fix Google Cloud (gcloud) & Azure CLI (az login) SSL Certificate Errors on Mac](<https://swgbar.com/en/guides/fix-gcloud-azure-cli-ssl-certificate-verify-failed-mac/>)
*   [Fix Firefox 'SEC\_ERROR\_UNKNOWN\_ISSUER' Behind Zscaler & Corporate SWGs on Mac](<https://swgbar.com/en/guides/fix-firefox-sec-error-unknown-issuer-mac/>)
*   [Fix Ruby, Bundler & CocoaPods OpenSSL::SSL::SSLError on Mac](<https://swgbar.com/en/guides/fix-ruby-bundler-cocoapods-fastlane-ssl-error-mac/>)
*   [Fix Rust (cargo/rustup) & Go x509 SSL Errors on Mac](<https://swgbar.com/en/guides/fix-rust-cargo-rustup-go-ssl-x509-error-mac/>)
*   [Fix kubectl, Helm & Minikube x509 Unknown Authority on Mac](<https://swgbar.com/en/guides/fix-kubernetes-kubectl-helm-minikube-x509-mac/>)
*   [Fix curl (60), Wget & PHP Composer SSL Certificate Errors on Mac](<https://swgbar.com/en/guides/fix-curl-60-wget-php-composer-ssl-error-mac/>)
*   [Confirmed vs. Suspected HTTPS inspection in SWG bar](<https://swgbar.com/en/guides/confirmed-vs-suspected-https-inspection/>)
*   [Inspect MITM root certificates & issuers in SWG bar](<https://swgbar.com/en/guides/inspect-mitm-root-certificates-macos/>)
*   [Enterprise SWG & MDM HTTPS inspection on a Mac](<https://swgbar.com/en/guides/enterprise-swg-https-inspection-macos/>)
*   [SWG bypass vs. TLS inspection exception (break and inspect)](<https://swgbar.com/en/guides/swg-bypass-vs-tls-exception/>)
*   [Bypass SWG for multi-domain web apps, SSO, CDNs & APIs on Mac](<https://swgbar.com/en/guides/multi-domain-sso-api-cdn-swg-bypass/>)
*   [Fix SWG bypass Recovering, Paused & connection errors on Mac](<https://swgbar.com/en/guides/troubleshoot-swg-bypass-recovering-paused-macos/>)
*   [macOS VPN virtual interfaces vs. SWG HTTPS inspection](<https://swgbar.com/en/guides/macos-vpn-virtual-interface-vs-swg-inspection/>)
*   [Why certificate-pinned apps & mTLS break under SWG inspection](<https://swgbar.com/en/guides/certificate-pinning-mtls-swg-inspection-macos/>)
*   [Fix SWG TLS & SSL certificate errors in CLI and AI tools on a Mac](<https://swgbar.com/en/guides/swg-tls-certificate-errors-macos/>)
*   [Homebrew, Docker, Python & Node.js CA trust behind an SWG on Mac](<https://swgbar.com/en/guides/homebrew-docker-python-node-ca-trust-swg-macos/>)
*   [Fix Claude Code & Cursor 'unable to get local issuer certificate' on Mac (SWG & MCP)](<https://swgbar.com/en/guides/ai-coding-agents-claude-code-cursor-swg-macos/>)
*   [Verify TLS certificates with openssl & security verify-cert on Mac](<https://swgbar.com/en/guides/verify-tls-certificates-openssl-security-verify-cert-macos/>)
*   [SWG bar permissions, local privacy & TLS probe limits](<https://swgbar.com/en/guides/macos-network-extension-privacy-probe-limits/>)
*   [How SWG bar checks HTTPS inspection](<https://swgbar.com/en/how-it-works/>)
*   [SWG bar Pricing — One-Time License for macOS (Personal & Team)](<https://swgbar.com/en/pricing/>)
*   [Download & install SWG bar for Mac (macOS 14+)](<https://swgbar.com/en/install/>)
*   [Chrome Extension to Detect SSL & HTTPS Inspection (SWG Bar Companion)](<https://swgbar.com/en/chrome-extension/>)
*   [SWG bar CLI Guide](<https://swgbar.com/en/cli/>)
*   [SWG bar MCP Server — macOS TLS Certificate Monitoring & SWG Bypass for Claude Code and Cursor](<https://swgbar.com/en/mcp/>)
*   [SWG bar release information](<https://swgbar.com/en/releases/>)
*   [About SWG bar](<https://swgbar.com/en/about/>)
