Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions httpie/ssl_.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,26 @@ def _create_ssl_context(
ciphers=ciphers,
ssl_version=resolve_ssl_version(ssl_version),
# Since we are using a custom SSL context, we need to pass this
# here manually, even though its also passed to the connection
# here manually, even though it's also passed to the connection
# in `super().cert_verify()`.
cert_reqs=ssl.CERT_REQUIRED if verify else ssl.CERT_NONE
)
ensure_default_certs_loaded(ssl_context)
# Ensure default certificates are loaded for proper SSL verification
# This addresses https://github.com/httpie/cli/issues/1632
if verify:
# First try the existing ensure_default_certs_loaded function
ensure_default_certs_loaded(ssl_context)

# Additional safety check for cases where certificates might not be loaded
# This handles the specific issue where create_urllib3_context()
# creates a context with 0 certificates
if hasattr(ssl_context, 'load_default_certs') and not ssl_context.get_ca_certs():
try:
ssl_context.load_default_certs()
except Exception:
# If loading fails, continue with what we have
# This preserves backward compatibility
pass
return ssl_context

@classmethod
Expand All @@ -106,4 +121,4 @@ def _is_key_file_encrypted(key_file):
# We used to import the default set of TLS ciphers from urllib3, but they removed it.
# Instead, now urllib3 uses the list of ciphers configured by the system.
# <https://github.com/httpie/cli/pull/1501>
DEFAULT_SSL_CIPHERS_STRING = ':'.join(HTTPieHTTPSAdapter.get_default_ciphers_names())
DEFAULT_SSL_CIPHERS_STRING = ':'.join(HTTPieHTTPSAdapter.get_default_ciphers_names())
Loading