Skip to content

Fix SSL certificate verification on macOS - #1941

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

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

Conversation

@vinayK34

Copy link
Copy Markdown

This fixes #1632 where HTTPie fails
to verify SSL certificates on macOS even though requests works fine in
the same environment.

The root cause is that urllib3.util.ssl_.create_urllib3_context() creates
SSL contexts without CA certificates, which causes certificate verification
to fail. This fix ensures that when verify=True, we load the default
certificates if needed.

Fixes the issue by:

  1. Ensuring certificates are loaded when verify=True
  2. Adding a safety check for contexts that might have 0 certificates
  3. Handling potential exceptions gracefully
  4. Preserving backward compatibility

This fixes httpie#1632 where HTTPie fails
to verify SSL certificates on macOS even though requests works fine in
the same environment.

The root cause is that urllib3.util.ssl_.create_urllib3_context() creates
SSL contexts without CA certificates, which causes certificate verification
to fail. This fix ensures that when verify=True, we load the default
certificates if needed.

Fixes the issue by:
1. Ensuring certificates are loaded when verify=True
2. Adding a safety check for contexts that might have 0 certificates
3. Handling potential exceptions gracefully
4. Preserving backward compatibility
@vinayK34
vinayK34 marked this pull request as ready for review August 26, 2026 06:12
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