summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2015-01-23 21:35:37 (GMT)
committerBenjamin Peterson <benjamin@python.org>2015-01-23 21:35:37 (GMT)
commitcca2732a8216bac0d6ca182fc5a55769af2c5160 (patch)
treefa98ed3d5c492db2748cc7afda34351795e4783f /Doc
parent06140f2e04eb23f88e2b9d13bd5388fe29addbaa (diff)
downloadcpython-cca2732a8216bac0d6ca182fc5a55769af2c5160.zip
cpython-cca2732a8216bac0d6ca182fc5a55769af2c5160.tar.gz
cpython-cca2732a8216bac0d6ca182fc5a55769af2c5160.tar.bz2
add support for ALPN (closes #20188)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/ssl.rst34
1 files changed, 32 insertions, 2 deletions
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
index d77c028..11b8aa9 100644
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -673,6 +673,13 @@ Constants
.. versionadded:: 3.3
+.. data:: HAS_ALPN
+
+ Whether the OpenSSL library has built-in support for the *Application-Layer
+ Protocol Negotiation* TLS extension as described in :rfc:`7301`.
+
+ .. versionadded:: 3.5
+
.. data:: HAS_ECDH
Whether the OpenSSL library has built-in support for Elliptic Curve-based
@@ -959,9 +966,18 @@ SSL sockets also have the following additional methods and attributes:
.. versionadded:: 3.3
+.. method:: SSLSocket.selected_alpn_protocol()
+
+ Return the protocol that was selected during the TLS handshake. If
+ :meth:`SSLContext.set_alpn_protocols` was not called, if the other party does
+ not support ALPN, or if the handshake has not happened yet, ``None`` is
+ returned.
+
+ .. versionadded:: 3.5
+
.. method:: SSLSocket.selected_npn_protocol()
- Returns the higher-level protocol that was selected during the TLS/SSL
+ Return the higher-level protocol that was selected during the TLS/SSL
handshake. If :meth:`SSLContext.set_npn_protocols` was not called, or
if the other party does not support NPN, or if the handshake has not yet
happened, this will return ``None``.
@@ -1160,6 +1176,20 @@ to speed up repeated connections from the same clients.
when connected, the :meth:`SSLSocket.cipher` method of SSL sockets will
give the currently selected cipher.
+.. method:: SSLContext.set_alpn_protocols(protocols)
+
+ Specify which protocols the socket should advertise during the SSL/TLS
+ handshake. It should be a list of ASCII strings, like ``['http/1.1',
+ 'spdy/2']``, ordered by preference. The selection of a protocol will happen
+ during the handshake, and will play out according to :rfc:`7301`. After a
+ successful handshake, the :meth:`SSLSocket.selected_alpn_protocol` method will
+ return the agreed-upon protocol.
+
+ This method will raise :exc:`NotImplementedError` if :data:`HAS_ALPN` is
+ False.
+
+ .. versionadded:: 3.5
+
.. method:: SSLContext.set_npn_protocols(protocols)
Specify which protocols the socket should advertise during the SSL/TLS
@@ -1200,7 +1230,7 @@ to speed up repeated connections from the same clients.
Due to the early negotiation phase of the TLS connection, only limited
methods and attributes are usable like
- :meth:`SSLSocket.selected_npn_protocol` and :attr:`SSLSocket.context`.
+ :meth:`SSLSocket.selected_alpn_protocol` and :attr:`SSLSocket.context`.
:meth:`SSLSocket.getpeercert`, :meth:`SSLSocket.getpeercert`,
:meth:`SSLSocket.cipher` and :meth:`SSLSocket.compress` methods require that
the TLS connection has progressed beyond the TLS Client Hello and therefore