@@ -41,21 +41,17 @@ def __init__(self, ca_provider: "CertificateAuthority"):
4141 self ._context_cache : Dict [str , ssl .SSLContext ] = {}
4242
4343 def get_domain_context (self , server_name : str ) -> ssl .SSLContext :
44- logger .debug (f"Getting domain context for server_name: { server_name } " )
45- if server_name not in self ._context_cache :
46- logger .debug (f"No cached SSL context for { server_name } , creating new one." )
47- cert_path , key_path = self ._ca .get_domain_certificate (server_name )
48- context = self ._create_domain_ssl_context (cert_path , key_path , server_name )
49- self ._context_cache [server_name ] = context
50- logger .debug (f"Created new SSL context for { server_name } " )
51- return self ._context_cache [server_name ]
44+ cert_path , key_path = self ._ca .get_domain_certificate (server_name )
45+ context = self ._create_domain_ssl_context (cert_path , key_path , server_name )
46+ return context
5247
5348 def _create_domain_ssl_context (
5449 self , cert_path : str , key_path : str , domain : str
5550 ) -> ssl .SSLContext :
5651 """
5752 Domain SNI Context Setting
5853 """
54+
5955 logger .debug (f"Loading cert chain from { cert_path } for domain { domain } " )
6056 context = ssl .SSLContext (ssl .PROTOCOL_TLS_SERVER )
6157 try :
@@ -364,8 +360,7 @@ def get_domain_certificate(self, domain: str) -> Tuple[str, str]:
364360 )
365361 # Check if certificate is still valid beyond the grace period
366362 expiry_date = datetime .now (timezone .utc ) + timedelta (days = TLS_GRACE_PERIOD_DAYS )
367- logger .debug (f"Expiry date: { expiry_date } " )
368- logger .debug (f"Certificate expiry: { domain_cert .not_valid_after } " )
363+ logger .debug (f"Certificate expiry: { domain_cert .not_valid_after_utc } " )
369364 if domain_cert .not_valid_after_utc > expiry_date :
370365 logger .debug (
371366 f"Using cached certificate for { domain } from { cached .cert_path } "
0 commit comments