Fix SSL certificate verification issue on macOS (fixes #1632) - #1929
Closed
vinayK34 wants to merge 1 commit into
Closed
Fix SSL certificate verification issue on macOS (fixes #1632)#1929vinayK34 wants to merge 1 commit into
vinayK34 wants to merge 1 commit into
Conversation
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
marked this pull request as ready for review
August 11, 2026 11:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
certifiis installed andrequestscan successfully verify certificates, HTTPie's SSL verification fails withSSLCertVerificationError: unable to get local issuer certificate.Root Cause
The issue stems from the
ensure_default_certs_loadedfunction inhttpie/compat.py. The original implementation only loads certificates ifget_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:
certifiif availableTesting
The fix has been tested in a sandbox environment and follows the same patterns used by the requests library for certificate verification.
Fixes #1632