1515from .._imports import dotenv , setproctitle , watchfiles
1616from .._internal import build_env_loader , load_target
1717from .._signals import set_main_signals
18- from ..constants import HTTPModes , Interfaces , Loops , RuntimeModes , TaskImpl
18+ from ..constants import HTTPModes , Interfaces , Loops , RuntimeModes , SSLProtocols , TaskImpl
1919from ..errors import ConfigurationError , PidFileError
2020from ..http import HTTP1Settings , HTTP2Settings
2121from ..log import DEFAULT_ACCESSLOG_FMT , LogLevels , configure_logging , logger
@@ -108,6 +108,7 @@ def __init__(
108108 ssl_cert : Optional [Path ] = None ,
109109 ssl_key : Optional [Path ] = None ,
110110 ssl_key_password : Optional [str ] = None ,
111+ ssl_protocol_min : SSLProtocols = SSLProtocols .tls13 ,
111112 ssl_ca : Optional [Path ] = None ,
112113 ssl_crl : Optional [List [Path ]] = None ,
113114 ssl_client_verify : bool = False ,
@@ -200,7 +201,9 @@ def __init__(
200201
201202 configure_logging (self .log_level , self .log_config , self .log_enabled )
202203
203- self .build_ssl_context (ssl_cert , ssl_key , ssl_key_password , ssl_ca , ssl_crl or [], ssl_client_verify )
204+ self .build_ssl_context (
205+ ssl_cert , ssl_key , ssl_key_password , ssl_protocol_min , ssl_ca , ssl_crl or [], ssl_client_verify
206+ )
204207 self ._ssp = None
205208 self ._shd = None
206209 self ._sfd = None
@@ -220,12 +223,13 @@ def build_ssl_context(
220223 cert : Optional [Path ],
221224 key : Optional [Path ],
222225 password : Optional [str ],
226+ proto : SSLProtocols ,
223227 ca : Optional [Path ],
224228 crl : List [Path ],
225229 client_verify : bool ,
226230 ):
227231 if not (cert and key ):
228- self .ssl_ctx = (False , None , None , None , None , [], False )
232+ self .ssl_ctx = (False , None , None , None , str ( proto ), None , [], False )
229233 return
230234 # uneeded?
231235 ctx = ssl .SSLContext (ssl .PROTOCOL_TLS_SERVER )
@@ -239,6 +243,7 @@ def build_ssl_context(
239243 str (cert .resolve ()),
240244 str (key .resolve ()),
241245 password ,
246+ str (proto ),
242247 str (ca .resolve ()) if ca else None ,
243248 [str (item .resolve ()) for item in crl ],
244249 client_verify ,
0 commit comments