[Python-checkins] [3.6] bpo-30714: ALPN changes for OpenSSL 1.1.0f (#3093)

Christian Heimes webhook-mailer at python.org
Tue Aug 15 04:45:45 EDT 2017


https://github.com/python/cpython/commit/7f6a13bd562ff6a265fc63a991327feaecb07a77
commit: 7f6a13bd562ff6a265fc63a991327feaecb07a77
branch: 3.6
author: Christian Heimes <christian at python.org>
committer: GitHub <noreply at github.com>
date: 2017-08-15T10:45:40+02:00
summary:

[3.6] bpo-30714: ALPN changes for OpenSSL 1.1.0f (#3093)

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 https://github.com/openssl/openssl/pull/3158 for more details

Signed-off-by: Christian Heimes <christian at python.org>
(cherry picked from commit a5c1bab352671e043645163ca50c5211aa657acd)

files:
A Misc/NEWS.d/next/Tests/2017-07-25-15-27-44.bpo-30715.Sp7bTF.rst
M Doc/library/ssl.rst
M Lib/test/test_ssl.py

diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
index 6c30a74a099..357f65a3faf 100644
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -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
 
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 85c59a618ce..3fdbba13705 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -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" \
diff --git a/Misc/NEWS.d/next/Tests/2017-07-25-15-27-44.bpo-30715.Sp7bTF.rst b/Misc/NEWS.d/next/Tests/2017-07-25-15-27-44.bpo-30715.Sp7bTF.rst
new file mode 100644
index 00000000000..88394e585c5
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2017-07-25-15-27-44.bpo-30715.Sp7bTF.rst
@@ -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.



More information about the Python-checkins mailing list