import ssl from requests.adapters import HTTPAdapter # noinspection PyPackageRequirements from urllib3.util.ssl_ import ( DEFAULT_CIPHERS, create_urllib3_context, resolve_ssl_version, ) DEFAULT_SSL_CIPHERS = DEFAULT_CIPHERS SSL_VERSION_ARG_MAPPING = { 'ssl2.3': 'PROTOCOL_SSLv23', 'ssl3': 'PROTOCOL_SSLv3', 'tls1': 'PROTOCOL_TLSv1', 'tls1.1': 'PROTOCOL_TLSv1_1', 'tls1.2': 'PROTOCOL_TLSv1_2', 'tls1.3': 'PROTOCOL_TLSv1_3', } AVAILABLE_SSL_VERSION_ARG_MAPPING = { arg: getattr(ssl, constant_name) for arg, constant_name in SSL_VERSION_ARG_MAPPING.items() if hasattr(ssl, constant_name) } class HTTPieHTTPSAdapter(HTTPAdapter): def __init__( self, verify: bool, ssl_version: str = None, ciphers: str = None, **kwargs ): self._ssl_context = self._create_ssl_context( verify=verify, ssl_version=ssl_version, ciphers=ciphers, ) super().__init__(**kwargs) def init_poolmanager(self, *args, **kwargs): kwargs['ssl_context'] = self._ssl_context return super().init_poolmanager(*args, **kwargs) def proxy_manager_for(self, *args, **kwargs): kwargs['ssl_context'] = self._ssl_context return super().proxy_manager_for(*args, **kwargs) @staticmethod def _create_ssl_context( verify: bool, ssl_version: str = None, ciphers: str = None, ) -> 'ssl.SSLContext': return create_urllib3_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 it’s also passed to the connection # in `super().cert_verify()`. cert_reqs=ssl.CERT_REQUIRED if verify else ssl.CERT_NONE )
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__pycache__ | Folder | 0755 |
|
|
cli | Folder | 0755 |
|
|
output | Folder | 0755 |
|
|
plugins | Folder | 0755 |
|
|
__init__.py | File | 132 B | 0644 |
|
__main__.py | File | 394 B | 0644 |
|
client.py | File | 10.15 KB | 0644 |
|
compat.py | File | 1.82 KB | 0644 |
|
config.py | File | 3.42 KB | 0644 |
|
context.py | File | 3.83 KB | 0644 |
|
core.py | File | 8.74 KB | 0644 |
|
downloads.py | File | 13.85 KB | 0644 |
|
encoding.py | File | 1.32 KB | 0644 |
|
models.py | File | 3.37 KB | 0644 |
|
sessions.py | File | 4.85 KB | 0644 |
|
ssl.py | File | 1.84 KB | 0644 |
|
status.py | File | 987 B | 0644 |
|
uploads.py | File | 4.01 KB | 0644 |
|
utils.py | File | 6.12 KB | 0644 |
|