Skip to content

Commit 2940b06

Browse files
committed
gh-154517: Document OpenSSL version requirements and post-quantum groups for the ssl group API
1 parent eb44708 commit 2940b06

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Doc/library/ssl.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,9 @@ SSL sockets also have the following additional methods and attributes:
13151315
Return the group used for doing key agreement on this connection. If no
13161316
connection has been established, returns ``None``.
13171317

1318+
This method requires OpenSSL 3.2 or later; it raises
1319+
:exc:`NotImplementedError` when linked against an older version.
1320+
13181321
.. versionadded:: 3.15
13191322

13201323
.. method:: SSLSocket.client_sigalg()
@@ -1707,6 +1710,9 @@ to speed up repeated connections from the same clients.
17071710
:const:`True` this method will also return any associated aliases such as
17081711
the ECDH curve names supported in older versions of OpenSSL.
17091712

1713+
This method requires OpenSSL 3.5 or later; it raises
1714+
:exc:`NotImplementedError` when linked against an older version.
1715+
17101716
.. versionadded:: 3.15
17111717

17121718
.. method:: SSLContext.set_default_verify_paths()
@@ -1754,6 +1760,19 @@ to speed up repeated connections from the same clients.
17541760
context. It should be a string in the `OpenSSL group list format
17551761
<https://docs.openssl.org/master/man3/SSL_CTX_set1_groups_list/>`_.
17561762

1763+
This is a more general replacement for :meth:`~SSLContext.set_ecdh_curve`:
1764+
it accepts several groups in order of preference and supports finite-field
1765+
and post-quantum hybrid groups in addition to ECDH curves. For example,
1766+
to prefer the post-quantum hybrid group ``X25519MLKEM768`` and fall back
1767+
to the classical ``X25519`` group::
1768+
1769+
>>> ctx = ssl.create_default_context()
1770+
>>> ctx.set_groups("X25519MLKEM768:X25519") # doctest: +SKIP
1771+
1772+
Post-quantum hybrid groups such as ``X25519MLKEM768`` require OpenSSL 3.5
1773+
or later. Requesting a group that the linked OpenSSL does not recognize
1774+
raises an :class:`SSLError`.
1775+
17571776
.. note::
17581777

17591778
When connected, the :meth:`SSLSocket.group` method of SSL sockets will
@@ -1911,6 +1930,10 @@ to speed up repeated connections from the same clients.
19111930

19121931
This method is not available if :data:`HAS_ECDH` is ``False``.
19131932

1933+
For more control, including selecting several groups in order of
1934+
preference or offering post-quantum hybrid groups, use the more general
1935+
:meth:`~SSLContext.set_groups` method.
1936+
19141937
.. versionadded:: 3.3
19151938

19161939
.. seealso::
@@ -2933,6 +2956,10 @@ of TLS/SSL. Some new TLS 1.3 features are not yet available.
29332956
and the method :meth:`SSLSocket.cipher` returns information about the
29342957
negotiated cipher for both TLS 1.3 and earlier versions once a connection
29352958
is established.
2959+
- Key agreement can use post-quantum hybrid groups such as
2960+
``X25519MLKEM768`` when linked against OpenSSL 3.5 or later, which offers
2961+
them by default. Use :meth:`SSLContext.set_groups` to choose which groups
2962+
are offered and :meth:`SSLSocket.group` to see which one was negotiated.
29362963
- Session tickets are no longer sent as part of the initial handshake and
29372964
are handled differently. :attr:`SSLSocket.session` and :class:`SSLSession`
29382965
are not compatible with TLS 1.3.

0 commit comments

Comments
 (0)