]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Add debug logging to SSLConfig (#378)
authorSeth Michael Larson <sethmichaellarson@gmail.com>
Tue, 24 Sep 2019 15:02:46 +0000 (10:02 -0500)
committerFlorimond Manca <florimond.manca@gmail.com>
Tue, 24 Sep 2019 15:02:46 +0000 (17:02 +0200)
httpx/config.py

index b7c5ee6465f76ad2f91cc190d279fa556adc3192..f0f694fa5da3d9ff7abdf6847ee4a5c61568013c 100644 (file)
@@ -6,7 +6,7 @@ from pathlib import Path
 import certifi
 
 from .__version__ import __version__
-from .utils import get_ca_bundle_from_env
+from .utils import get_ca_bundle_from_env, get_logger
 
 CertTypes = typing.Union[str, typing.Tuple[str, str], typing.Tuple[str, str, str]]
 VerifyTypes = typing.Union[str, bool, ssl.SSLContext]
@@ -40,6 +40,9 @@ DEFAULT_CIPHERS = ":".join(
 )
 
 
+logger = get_logger(__name__)
+
+
 class SSLConfig:
     """
     SSL Configuration.
@@ -91,6 +94,14 @@ class SSLConfig:
     ) -> ssl.SSLContext:
         http_versions = HTTPVersionConfig() if http_versions is None else http_versions
 
+        logger.debug(
+            f"load_ssl_context "
+            f"verify={self.verify!r} "
+            f"cert={self.cert!r} "
+            f"trust_env={self.trust_env!r} "
+            f"http_versions={http_versions!r}"
+        )
+
         if self.ssl_context is None:
             self.ssl_context = (
                 self.load_ssl_context_verify(http_versions=http_versions)
@@ -152,8 +163,10 @@ class SSLConfig:
             pass
 
         if ca_bundle_path.is_file():
+            logger.debug(f"load_verify_locations cafile={ca_bundle_path!s}")
             context.load_verify_locations(cafile=str(ca_bundle_path))
         elif ca_bundle_path.is_dir():
+            logger.debug(f"load_verify_locations capath={ca_bundle_path!s}")
             context.load_verify_locations(capath=str(ca_bundle_path))
 
         self._load_client_certs(context)