SSL Configuration.
"""
+ DEFAULT_CA_BUNDLE_PATH = Path(certifi.where())
+
def __init__(
self,
*,
self.verify = ca_bundle # type: ignore
if isinstance(self.verify, bool):
- ca_bundle_path = DEFAULT_CA_BUNDLE_PATH
+ ca_bundle_path = self.DEFAULT_CA_BUNDLE_PATH
elif Path(self.verify).exists():
ca_bundle_path = Path(self.verify)
else:
TimeoutConfig = Timeout # Synonym for backwards compat
-DEFAULT_SSL_CONFIG = SSLConfig(cert=None, verify=True)
DEFAULT_TIMEOUT_CONFIG = Timeout(timeout=5.0)
DEFAULT_POOL_LIMITS = PoolLimits(soft_limit=10, hard_limit=100)
-DEFAULT_CA_BUNDLE_PATH = Path(certifi.where())
DEFAULT_MAX_REDIRECTS = 20
import sys
from pathlib import Path
+import certifi
import pytest
import httpx
def test_load_ssl_config_verify_existing_file():
- ssl_config = SSLConfig(verify=httpx.config.DEFAULT_CA_BUNDLE_PATH)
+ ssl_config = SSLConfig(verify=certifi.where())
context = ssl_config.load_ssl_context()
assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED
assert context.check_hostname is True
def test_load_ssl_config_verify_directory():
- path = httpx.config.DEFAULT_CA_BUNDLE_PATH.parent
+ path = Path(certifi.where()).parent
ssl_config = SSLConfig(verify=path)
context = ssl_config.load_ssl_context()
assert context.verify_mode == ssl.VerifyMode.CERT_REQUIRED