Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0cedb3b

Browse filesBrowse files
authored
Restore context.set_ciphers() to create_urllib3_context() (#1463)
1 parent 0aeba3b commit 0cedb3b
Copy full SHA for 0cedb3b

File tree

3 files changed

+22
-0
lines changed
Filter options

3 files changed

+22
-0
lines changed

‎CHANGES.rst

Copy file name to clipboardExpand all lines: CHANGES.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ dev (master)
66

77
* Remove quadratic behavior within ``GzipDecoder.decompress()`` (Issue #1467)
88

9+
* Restored functionality of `ciphers` parameter for `create_urllib3_context()`. (Issue #1462)
10+
911
* ... [Short description of non-trivial change.] (Issue #)
1012

1113

‎src/urllib3/util/ssl_.py

Copy file name to clipboardExpand all lines: src/urllib3/util/ssl_.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ def create_urllib3_context(ssl_version=None, cert_reqs=None,
263263
"""
264264
context = SSLContext(ssl_version or ssl.PROTOCOL_SSLv23)
265265

266+
context.set_ciphers(ciphers or DEFAULT_CIPHERS)
267+
266268
# Setting the default here, as we may have no ssl module on import
267269
cert_reqs = ssl.CERT_REQUIRED if cert_reqs is None else cert_reqs
268270

‎test/test_ssl.py

Copy file name to clipboardExpand all lines: test/test_ssl.py
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,21 @@ def test_sni_missing_warning_with_ip_addresses(monkeypatch, has_sni, server_host
7070
assert SNIMissingWarning in warnings
7171
else:
7272
assert warn.call_count == 0
73+
74+
75+
@pytest.mark.parametrize(
76+
["ciphers", "expected_ciphers"],
77+
[(None, ssl_.DEFAULT_CIPHERS),
78+
("ECDH+AESGCM:ECDH+CHACHA20", "ECDH+AESGCM:ECDH+CHACHA20")]
79+
)
80+
def test_create_urllib3_context_set_ciphers(monkeypatch, ciphers, expected_ciphers):
81+
82+
context = mock.create_autospec(ssl_.SSLContext)
83+
context.set_ciphers = mock.Mock()
84+
context.options = 0
85+
monkeypatch.setattr(ssl_, "SSLContext", lambda *_, **__: context)
86+
87+
assert ssl_.create_urllib3_context(ciphers=ciphers) is context
88+
89+
assert context.set_ciphers.call_count == 1
90+
assert context.set_ciphers.call_args == mock.call(expected_ciphers)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.