1 Adjust for OpenSSL 1.1.1:
3 https://github.com/pyca/pyopenssl/issues/1043
7 https://github.com/pyca/pyopenssl/commit/cc5c00ae5fd3c19d07fff79b5c4a08f5e58697ad
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']``.
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
21 + raise ValueError("at least one protocol must be specified")
23 # Take the list of protocols and join them together, prefixing them
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']``.
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
34 + raise ValueError("at least one protocol must be specified")
36 # Take the list of protocols and join them together, prefixing them
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.
46 context = Context(SSLv23_METHOD)
47 - with pytest.raises(Error):
48 + with pytest.raises(ValueError):
49 context.set_alpn_protos([])
51 def test_alpn_set_on_connection(self):