]> granicus.if.org Git - python/commitdiff
bpo-30714: ALPN changes for OpenSSL 1.1.0f (#2305)
authorChristian Heimes <christian@python.org>
Tue, 15 Aug 2017 08:33:43 +0000 (10:33 +0200)
committerGitHub <noreply@github.com>
Tue, 15 Aug 2017 08:33:43 +0000 (10:33 +0200)
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@python.org>
Doc/library/ssl.rst
Lib/test/test_ssl.py
Misc/NEWS.d/next/Tests/2017-07-25-15-27-44.bpo-30715.Sp7bTF.rst [new file with mode: 0644]

index 729a239a1baff59367603ffd2e7b2bdcf5e14948..0a09e7e9d4c4437faa545e5acff3e4d39c27ee0d 100644 (file)
@@ -1447,8 +1447,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
 
index d960d8206509d7cce8c5085f1528951c989d237d..104b7f377a52dbfb108c6d526d24286b515267b3 100644 (file)
@@ -3268,8 +3268,9 @@ if _have_threads:
                 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 (file)
index 0000000..88394e5
--- /dev/null
@@ -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.