Skip to content

Fix SSL certificate verification issue on macOS (fixes #1632) - #1929

Closed
vinayK34 wants to merge 1 commit into
httpie:masterfrom
vinayK34:fix/issue-1632-ssl-cert-verification
Closed

Fix SSL certificate verification issue on macOS (fixes #1632)#1929
vinayK34 wants to merge 1 commit into
httpie:masterfrom
vinayK34:fix/issue-1632-ssl-cert-verification

Conversation

@vinayK34

Copy link
Copy Markdown

This PR fixes SSL certificate verification issues on macOS where HTTPie fails to verify SSL certificates even when certifi is installed and requests works correctly.

Problem

On macOS systems, the default certificate loading mechanism in HTTPie fails intermittently. Even though certifi is installed and requests can successfully verify certificates, HTTPie's SSL verification fails with SSLCertVerificationError: unable to get local issuer certificate.

Root Cause

The issue stems from the ensure_default_certs_loaded function in httpie/compat.py. The original implementation only loads certificates if get_ca_certs() returns an empty list, but on some macOS systems, this check can fail or certificates might not be properly loaded despite the method succeeding.

Solution

This fix improves the robustness of SSL certificate loading by:

  1. Always attempting to load default certificates first
  2. Adding verification that certificates were actually loaded
  3. Providing a fallback to use certifi if available
  4. Including proper error handling to prevent complete SSL failures

Testing

The fix has been tested in a sandbox environment and follows the same patterns used by the requests library for certificate verification.

Fixes #1632

This fix improves the robustness of SSL certificate loading on macOS systems 
where the default certificate loading mechanism fails. The fix attempts multiple 
approaches to ensure certificates are properly loaded, including:
1. Standard load_default_certs() call
2. Fallback to certifi if available
3. Proper error handling to avoid complete SSL failures

The issue was that on macOS, even though certifi is installed and requests works,
HTTPie's SSL verification was failing because the certificate store wasn't being 
loaded properly in some environments.
@vinayK34
vinayK34 marked this pull request as ready for review August 11, 2026 11:52
@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.

HTTPie does not work on macOS unless certificate bundle is explicitly specified, even though requests does

1 participant