File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1421,6 +1421,12 @@ def set_alpn_protos(self, protos):
1421
1421
This list should be a Python list of bytestrings representing the
1422
1422
protocols to offer, e.g. ``[b'http/1.1', b'spdy/2']``.
1423
1423
"""
1424
+ # Different versions of OpenSSL are inconsistent about how they handle
1425
+ # empty proto lists (see #1043), so we avoid the problem entirely by
1426
+ # rejecting them ourselves.
1427
+ if not protos :
1428
+ raise ValueError ("at least one protocol must be specified" )
1429
+
1424
1430
# Take the list of protocols and join them together, prefixing them
1425
1431
# with their lengths.
1426
1432
protostr = b"" .join (
@@ -2449,6 +2455,12 @@ def set_alpn_protos(self, protos):
2449
2455
This list should be a Python list of bytestrings representing the
2450
2456
protocols to offer, e.g. ``[b'http/1.1', b'spdy/2']``.
2451
2457
"""
2458
+ # Different versions of OpenSSL are inconsistent about how they handle
2459
+ # empty proto lists (see #1043), so we avoid the problem entirely by
2460
+ # rejecting them ourselves.
2461
+ if not protos :
2462
+ raise ValueError ("at least one protocol must be specified" )
2463
+
2452
2464
# Take the list of protocols and join them together, prefixing them
2453
2465
# with their lengths.
2454
2466
protostr = b"" .join (
Original file line number Diff line number Diff line change @@ -1928,7 +1928,7 @@ def test_alpn_call_failure(self):
1928
1928
protocols list. Ensure that we produce a user-visible error.
1929
1929
"""
1930
1930
context = Context (SSLv23_METHOD )
1931
- with pytest .raises (Error ):
1931
+ with pytest .raises (ValueError ):
1932
1932
context .set_alpn_protos ([])
1933
1933
1934
1934
def test_alpn_set_on_connection (self ):
You can’t perform that action at this time.
0 commit comments