Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / patches / python2-pyopenssl-openssl-compat.patch
1 Adjust for OpenSSL 1.1.1:
2
3 https://github.com/pyca/pyopenssl/issues/1043
4
5 Taken from upstream:
6
7 https://github.com/pyca/pyopenssl/commit/cc5c00ae5fd3c19d07fff79b5c4a08f5e58697ad
8
9 diff --git a/src/OpenSSL/SSL.py b/src/OpenSSL/SSL.py
10 index 59f21cec..fcdee047 100644
11 --- a/src/OpenSSL/SSL.py
12 +++ b/src/OpenSSL/SSL.py
13 @@ -1421,6 +1421,12 @@ def set_alpn_protos(self, protos):
14 This list should be a Python list of bytestrings representing the
15 protocols to offer, e.g. ``[b'http/1.1', b'spdy/2']``.
16 """
17 + # Different versions of OpenSSL are inconsistent about how they handle empty
18 + # proto lists (see #1043), so we avoid the problem entirely by rejecting them
19 + # ourselves.
20 + if not protos:
21 + raise ValueError("at least one protocol must be specified")
22 +
23 # Take the list of protocols and join them together, prefixing them
24 # with their lengths.
25 protostr = b"".join(
26 @@ -2449,6 +2455,12 @@ def set_alpn_protos(self, protos):
27 This list should be a Python list of bytestrings representing the
28 protocols to offer, e.g. ``[b'http/1.1', b'spdy/2']``.
29 """
30 + # Different versions of OpenSSL are inconsistent about how they handle empty
31 + # proto lists (see #1043), so we avoid the problem entirely by rejecting them
32 + # ourselves.
33 + if not protos:
34 + raise ValueError("at least one protocol must be specified")
35 +
36 # Take the list of protocols and join them together, prefixing them
37 # with their lengths.
38 protostr = b"".join(
39 diff --git a/tests/test_ssl.py b/tests/test_ssl.py
40 index ffc505d8..ca363b45 100644
41 --- a/tests/test_ssl.py
42 +++ b/tests/test_ssl.py
43 @@ -1928,7 +1928,7 @@ def test_alpn_call_failure(self):
44 protocols list. Ensure that we produce a user-visible error.
45 """
46 context = Context(SSLv23_METHOD)
47 - with pytest.raises(Error):
48 + with pytest.raises(ValueError):
49 context.set_alpn_protos([])
50
51 def test_alpn_set_on_connection(self):