Fix Ruby, Bundler & CocoaPods OpenSSL::SSL::SSLError on Mac

Fix Ruby, Bundler, CocoaPods & Fastlane OpenSSL::SSL::SSLError behind Zscaler, Cloudflare WARP, or Netskope on macOS without disabling TLS verification.

SWG bar · Updated

When running bundle install, gem install, pod install, or fastlane on a corporate Mac behind Zscaler, Cloudflare WARP, Netskope, Cisco Umbrella, Palo Alto GlobalProtect, or Fortinet, Ruby’s OpenSSL stack frequently aborts with:

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error:
certificate verify failed (unable to get local issuer certificate)

Bundler::Fetcher::CertificateFailureError: Could not verify the SSL certificate
for https://rubygems.org/.

On iOS and macOS teams using CocoaPods or Fastlane, the exact same corporate HTTPS inspection surfaces as CDN: trunk Repo update failed or Spaceship / App Store Connect TLS handshake failures. Paste your exact log into the free SWG & SSL Error Decoder or apply the upgrade-safe macOS trust-store fix below.

1. Why Ruby, CocoaPods & Fastlane reject corporate SWG certificates

Safari and Chrome validate TLS chains through macOS System Keychain, where MDM installs your company’s SWG Root CA. Homebrew Ruby, rbenv, asdf, mise, and chruby compile against Homebrew’s OpenSSL (openssl@3), which reads a static PEM file (cert.pem) instead of macOS Keychain.

Check which certificate file your active Ruby binary currently trusts:

which ruby
ruby -ropenssl -e 'puts "DEFAULT_CERT_FILE=#{OpenSSL::X509::DEFAULT_CERT_FILE}"; puts "SSL_CERT_FILE=#{ENV["SSL_CERT_FILE"]}"'

If you overwrite Homebrew’s cert.pem in place, the next brew upgrade ca-certificates silently wipes your corporate CA. And if you set SSL_CERT_FILE to only your corporate SWG root certificate, every non-inspected HTTPS endpoint immediately breaks.

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

Create a single combined PEM file in ~/.certs/ruby-combined-ca.pem containing all built-in macOS public 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/ruby-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/ruby-combined-ca.pem"

Because both standard public roots and your corporate SWG root live in one file, inspected registries (rubygems.org, cdn.cocoapods.org) and bypassed endpoints both validate cleanly.

3. Persist CA trust for Ruby, Bundler, CocoaPods & Fastlane

Export SSL_CERT_FILE (for Ruby OpenSSL::SSL and RubyGems) and CURL_CA_BUNDLE (for CocoaPods trunk CDN and Fastlane’s typhoeus/libcurl requests) in ~/.zshrc:

cat <<'EOF' >> ~/.zshrc
export SSL_CERT_FILE="$HOME/.certs/ruby-combined-ca.pem"
export CURL_CA_BUNDLE="$HOME/.certs/ruby-combined-ca.pem"
EOF
source ~/.zshrc

Then configure Bundler and Git (which CocoaPods invokes for Git-hosted podspecs) to reference the same bundle:

bundle config set ssl_ca_cert "$HOME/.certs/ruby-combined-ca.pem"
git config --global http.sslCAInfo "$HOME/.certs/ruby-combined-ca.pem"

Verify cleanly without ever disabling TLS verification (never add :ssl_verify_mode: 0 to ~/.gemrc or set OpenSSL::SSL::VERIFY_NONE):

ruby -ropen-uri -e 'puts URI.open("https://rubygems.org/api/v1/versions/bundler/latest.json").status.inspect'
bundle install
pod repo update

4. Fix Xcode Run Scripts, rbenv & non-interactive shells

If bundle install works in Terminal but fails inside Xcode Build Phases, Fastlane GUI runners, or IDE tasks, that process does not load ~/.zshrc. Two clean fixes cover GUI and non-interactive launches:

  • Persist Bundler’s global setting: bundle config set ssl_ca_cert "$HOME/.certs/ruby-combined-ca.pem" writes to ~/.bundle/config, so every bundle exec pod install or bundle exec fastlane invocation inherits it even without shell environment variables.
  • Export for GUI apps in the current macOS login session:
    launchctl setenv SSL_CERT_FILE "$HOME/.certs/ruby-combined-ca.pem"
    launchctl setenv CURL_CA_BUNDLE "$HOME/.certs/ruby-combined-ca.pem"
    Restart Xcode after running launchctl setenv.

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

Some Apple and developer endpoints use strict certificate validation or rotate intermediates frequently, causing repeated trust-store breakage across Ruby upgrades. Where your company’s policy permits per-domain SWG bypass for developer package registries, SWG bar detects which hosts are intercepted and restores the authentic TLS certificate per domain in one click—keeping your corporate VPN and SSO intact (with a 14 actual-use-day free trial):

swgbar probe rubygems.org
swgbar bypass enable rubygems.org
swgbar bypass enable cdn.cocoapods.org

Working across mobile and full-stack toolchains on the same work Mac? Read Fix Git & npm SSL certificate errors on Mac, Fix Java, Maven, Gradle, IntelliJ & Android Studio PKIX path building failed on Mac, and How to bypass SWG on a Mac.