Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit 088a1e1

Browse files
committed
Do not modify global context var in TLS class
Use local ssl_context variable instead of global context variable. Respect 80 columns limit and add ´param´ in front of new argument in comments
1 parent cd2480d commit 088a1e1

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

hyper/http20/connection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ class HTTP20Connection(object):
5151
:param enable_push: (optional) Whether the server is allowed to push
5252
resources to the client (see
5353
:meth:`get_pushes() <hyper.HTTP20Connection.get_pushes>`).
54-
:ssl_context: (optional) A class with custom certificate settings. If not provided
55-
then hyper's default SSLContext is used instead.
54+
:param ssl_context: (optional) A class with custom certificate settings.
55+
If not provided then hyper's default SSLContext is used instead.
5656
"""
57-
def __init__(self, host, port=None, window_manager=None, enable_push=False, ssl_context=None,
58-
**kwargs):
57+
def __init__(self, host, port=None, window_manager=None, enable_push=False,
58+
ssl_context=None, **kwargs):
5959
"""
6060
Creates an HTTP/2 connection to a specific server.
6161
"""

hyper/tls.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ def wrap_socket(sock, server_hostname, ssl_context=None):
3131
global _context
3232

3333
if _context is None: # pragma: no cover
34-
_context = ssl_context or _init_context()
34+
_context = _init_context()
35+
36+
# if an SSLContext is provided then use it instead of default context
37+
_ssl_context = ssl_context or _context
3538

3639
# the spec requires SNI support
37-
ssl_sock = _context.wrap_socket(sock, server_hostname=server_hostname)
40+
ssl_sock = _ssl_context.wrap_socket(sock, server_hostname=server_hostname)
3841
# Setting SSLContext.check_hostname to True only verifies that the
3942
# post-handshake servername matches that of the certificate. We also need
4043
# to check that it matches the requested one.

0 commit comments

Comments
 (0)