Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add httpx.SSLContext configuration. #3022

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions httpx/_config.py
Expand Up @@ -43,14 +43,11 @@ class UnsetType:
class SSLContext(ssl.SSLContext):
DEFAULT_CA_BUNDLE_PATH = Path(certifi.where())

def __new__(
cls,
protocol: ssl._SSLMethod = ssl.PROTOCOL_TLS_CLIENT,
def __init__(
self,
verify: VerifyTypes = True,
cert: typing.Optional[CertTypes] = None,
) -> "SSLContext":
self = super().__new__(cls, protocol)

) -> None:
set_minimum_tls_version_1_2(self)
self.options |= ssl.OP_NO_COMPRESSION
self.set_ciphers(DEFAULT_CIPHERS)
Expand All @@ -65,7 +62,6 @@ def __new__(
self.load_ssl_context_verify(cert, verify)
else:
self.load_ssl_context_no_verify(cert)
return self

def load_ssl_context_no_verify(
self, cert: typing.Optional[CertTypes]
Expand Down Expand Up @@ -138,6 +134,14 @@ def _load_client_certs(self, cert: typing.Optional[CertTypes] = None) -> None:
password=cert[2], # type: ignore
)

def __new__(
cls,
protocol: ssl._SSLMethod = ssl.PROTOCOL_TLS_CLIENT,
*args: typing.Any,
**kwargs: typing.Any,
) -> "SSLContext":
return super().__new__(cls, protocol, *args, **kwargs)
karpetrosyan marked this conversation as resolved.
Show resolved Hide resolved


class Timeout:
"""
Expand Down