Skip to content

Commit

Permalink
chore: initial exploration on a good default context
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jan 18, 2024
1 parent b2239ef commit 233b5eb
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/netius/base/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 233b5eb

Please sign in to comment.