Skip to content

Fix SSL certificate loading on macOS systems - #1928

Closed
vinayK34 wants to merge 1 commit into
httpie:masterfrom
vinayK34:fix/macos-ssl-certificates
Closed

Fix SSL certificate loading on macOS systems#1928
vinayK34 wants to merge 1 commit into
httpie:masterfrom
vinayK34:fix/macos-ssl-certificates

Conversation

@vinayK34

Copy link
Copy Markdown

This PR fixes the issue where HTTPie fails to verify SSL certificates on macOS systems even when certifi is installed.

Problem

On macOS, when verify=True (which is the default), HTTPie fails with:

SSLError: HTTPSConnectionPool(host='google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1028)')))

The root cause is that the default certificate loading mechanism doesn't work properly on macOS systems, causing certificate verification to fail.

Solution

The fix modifies ensure_default_certs_loaded in httpie/compat.py to:

  1. Detect macOS systems
  2. Attempt to load certificates using certifi.where() as a fallback when load_default_certs() fails
  3. This ensures that on macOS, certificates are properly loaded from the system trust store or certifi when available

Testing

This fix has been tested on macOS and should resolve the issue described in #1632 where https get google.com fails with certificate verification errors.

This fix addresses the issue where HTTPie fails to verify SSL certificates on macOS
systems even when certifi is installed. The problem occurs because the default
certificate loading mechanism doesn't work properly on macOS, causing
"SSLCertVerificationError: certificate verify failed: unable to get local issuer certificate"
errors.

The fix detects macOS systems and attempts to load certificates using certifi as a
fallback when the default load_default_certs() fails.
@vinayK34
vinayK34 marked this pull request as ready for review August 11, 2026 07:08
@vinayK34 vinayK34 closed this Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant