Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | From 7b40cb7293cb14e5c7c8ed123efaf9acb33edae2 Mon Sep 17 00:00:00 2001 |
| 2 | From: Christian Heimes <christian@python.org> |
| 3 | Date: Tue, 15 Aug 2017 10:33:43 +0200 |
| 4 | Subject: [PATCH] bpo-30714: ALPN changes for OpenSSL 1.1.0f (#2305) |
| 5 | |
| 6 | OpenSSL 1.1.0 to 1.1.0e aborted the handshake when server and client |
| 7 | could not agree on a protocol using ALPN. OpenSSL 1.1.0f changed that. |
| 8 | The most recent version now behaves like OpenSSL 1.0.2 again. The ALPN |
| 9 | callback can pretend to not been set. |
| 10 | |
| 11 | See https://github.com/openssl/openssl/pull/3158 for more details |
| 12 | |
| 13 | Signed-off-by: Christian Heimes <christian@python.org> |
| 14 | |
| 15 | Upstream-Status: Backport |
| 16 | [https://github.com/python/cpython/commit/7b40cb7293cb14e5c7c8ed123efaf9acb33edae2] |
| 17 | |
| 18 | Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> |
| 19 | --- |
| 20 | Doc/library/ssl.rst | 5 +++-- |
| 21 | Lib/test/test_ssl.py | 5 +++-- |
| 22 | .../next/Tests/2017-07-25-15-27-44.bpo-30715.Sp7bTF.rst | 2 ++ |
| 23 | 3 files changed, 8 insertions(+), 4 deletions(-) |
| 24 | create mode 100644 Misc/NEWS.d/next/Tests/2017-07-25-15-27-44.bpo-30715.Sp7bTF.rst |
| 25 | |
| 26 | diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst |
| 27 | index 729a239a1b..0a09e7e9d4 100644 |
| 28 | --- a/Doc/library/ssl.rst |
| 29 | +++ b/Doc/library/ssl.rst |
| 30 | @@ -1447,8 +1447,9 @@ to speed up repeated connections from the same clients. |
| 31 | This method will raise :exc:`NotImplementedError` if :data:`HAS_ALPN` is |
| 32 | False. |
| 33 | |
| 34 | - OpenSSL 1.1.0+ will abort the handshake and raise :exc:`SSLError` when |
| 35 | - both sides support ALPN but cannot agree on a protocol. |
| 36 | + OpenSSL 1.1.0 to 1.1.0e will abort the handshake and raise :exc:`SSLError` |
| 37 | + when both sides support ALPN but cannot agree on a protocol. 1.1.0f+ |
| 38 | + behaves like 1.0.2, :meth:`SSLSocket.selected_alpn_protocol` returns None. |
| 39 | |
| 40 | .. versionadded:: 3.5 |
| 41 | |
| 42 | diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py |
| 43 | index d960d82065..104b7f377a 100644 |
| 44 | --- a/Lib/test/test_ssl.py |
| 45 | +++ b/Lib/test/test_ssl.py |
| 46 | @@ -3268,8 +3268,9 @@ if _have_threads: |
| 47 | except ssl.SSLError as e: |
| 48 | stats = e |
| 49 | |
| 50 | - if expected is None and IS_OPENSSL_1_1: |
| 51 | - # OpenSSL 1.1.0 raises handshake error |
| 52 | + if (expected is None and IS_OPENSSL_1_1 |
| 53 | + and ssl.OPENSSL_VERSION_INFO < (1, 1, 0, 6)): |
| 54 | + # OpenSSL 1.1.0 to 1.1.0e raises handshake error |
| 55 | self.assertIsInstance(stats, ssl.SSLError) |
| 56 | else: |
| 57 | msg = "failed trying %s (s) and %s (c).\n" \ |
| 58 | 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 |
| 59 | new file mode 100644 |
| 60 | index 0000000000..88394e585c |
| 61 | --- /dev/null |
| 62 | +++ b/Misc/NEWS.d/next/Tests/2017-07-25-15-27-44.bpo-30715.Sp7bTF.rst |
| 63 | @@ -0,0 +1,2 @@ |
| 64 | +Address ALPN callback changes for OpenSSL 1.1.0f. The latest version behaves |
| 65 | +like OpenSSL 1.0.2 and no longer aborts handshake. |
| 66 | -- |
| 67 | 2.17.1 |
| 68 | |