From 233b5eb431971dcb2a12840c94104763acb88f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= Date: Thu, 18 Jan 2024 09:12:49 +0000 Subject: [PATCH] chore: initial exploration on a good default context --- src/netius/base/common.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/netius/base/common.py b/src/netius/base/common.py index d3a589e2..9a629bbe 100644 --- a/src/netius/base/common.py +++ b/src/netius/base/common.py @@ -3591,13 +3591,14 @@ def _ssl_init(self, strict = True, env = True): # is available, so that proper concrete context may be set, note # that in case the strict mode is enabled (default) the context # is unset for situation where no callback registration is possible - self._ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) - self._ssl_ctx_base( - self._ssl_context, - secure = secure, - context_options = context_options - ) - self._ssl_ctx_protocols(self._ssl_context) + self._ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) + #self._ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) + #self._ssl_ctx_base( + # self._ssl_context, + # secure = secure, + # context_options = context_options + #) + #self._ssl_ctx_protocols(self._ssl_context) self._ssl_certs(self._ssl_context) has_callback = hasattr(self._ssl_context, "set_servername_callback") if has_callback: self._ssl_context.set_servername_callback(self._ssl_callback) @@ -3683,14 +3684,14 @@ def _ssl_ctx_alpn(self, context): if not ssl.HAS_ALPN: return if hasattr(context, "set_alpn_protocols"): protocols = self.get_protocols() - protocols and context.set_alpn_protocols(protocols) + if protocols: context.set_alpn_protocols(protocols) def _ssl_ctx_npn(self, context): if not hasattr(ssl, "HAS_NPN"): return if not ssl.HAS_NPN: return if hasattr(context, "set_npn_protocols"): protocols = self.get_protocols() - protocols and context.set_npn_protocols(protocols) + if protocols: context.set_npn_protocols(protocols) def _ssl_certs( self,