Skip to content

Commit

Permalink
[3.6] bpo-30714: ALPN changes for OpenSSL 1.1.0f (#3093)
Browse files Browse the repository at this point in the history
OpenSSL 1.1.0 to 1.1.0e aborted the handshake when server and client
could not agree on a protocol using ALPN. OpenSSL 1.1.0f changed that.
The most recent version now behaves like OpenSSL 1.0.2 again. The ALPN
callback can pretend to not been set.

See openssl/openssl#3158 for more details

Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit a5c1bab)
  • Loading branch information
tiran committed Aug 15, 2017
1 parent a314590 commit 7f6a13b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Doc/library/ssl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1442,8 +1442,9 @@ to speed up repeated connections from the same clients.
This method will raise :exc:`NotImplementedError` if :data:`HAS_ALPN` is
False.

OpenSSL 1.1.0+ will abort the handshake and raise :exc:`SSLError` when
both sides support ALPN but cannot agree on a protocol.
OpenSSL 1.1.0 to 1.1.0e will abort the handshake and raise :exc:`SSLError`
when both sides support ALPN but cannot agree on a protocol. 1.1.0f+
behaves like 1.0.2, :meth:`SSLSocket.selected_alpn_protocol` returns None.

.. versionadded:: 3.5

Expand Down
5 changes: 3 additions & 2 deletions Lib/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3258,8 +3258,9 @@ def test_alpn_protocols(self):
except ssl.SSLError as e:
stats = e

if expected is None and IS_OPENSSL_1_1:
# OpenSSL 1.1.0 raises handshake error
if (expected is None and IS_OPENSSL_1_1
and ssl.OPENSSL_VERSION_INFO < (1, 1, 0, 6)):
# OpenSSL 1.1.0 to 1.1.0e raises handshake error
self.assertIsInstance(stats, ssl.SSLError)
else:
msg = "failed trying %s (s) and %s (c).\n" \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Address ALPN callback changes for OpenSSL 1.1.0f. The latest version behaves
like OpenSSL 1.0.2 and no longer aborts handshake.

0 comments on commit 7f6a13b

Please sign in to comment.