[3.13] gh-118596: Add thread-safety clarifications to the SSLContext documentation (GH-118597) (#120595)

gh-118596: Add thread-safety clarifications to the SSLContext documentation (GH-118597)

Add thread-safety clarifications to the SSLContext documentation. Per the issue:

This issue has also come up [here](https://github.com/psf/requests/pull/6667) where the matter was clarified by @tiran in [this comment](https://github.com/psf/requests/pull/6667):
> `SSLContext` is designed to be shared and used for multiple connections. It is thread safe as long as you don't reconfigure it once it is used by a connection. Adding new certs to the internal trust store is fine, but changing ciphers, verification settings, or mTLS certs can lead to surprising behavior. The problem is unrelated to threads and can even occur in a single-threaded program.
(cherry picked from commit 4f59f86382)

Co-authored-by: mm-matthias <43849132+mm-matthias@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-06-16 22:43:20 +02:00 committed by GitHub
parent 1c41aa78d8
commit 7655989a3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 0 deletions

View File

@ -1472,6 +1472,19 @@ to speed up repeated connections from the same clients.
:data:`PROTOCOL_TLS`, :data:`PROTOCOL_TLS_CLIENT`, and :data:`PROTOCOL_TLS`, :data:`PROTOCOL_TLS_CLIENT`, and
:data:`PROTOCOL_TLS_SERVER` use TLS 1.2 as minimum TLS version. :data:`PROTOCOL_TLS_SERVER` use TLS 1.2 as minimum TLS version.
.. note::
:class:`SSLContext` only supports limited mutation once it has been used
by a connection. Adding new certificates to the internal trust store is
allowed, but changing ciphers, verification settings, or mTLS
certificates may result in surprising behavior.
.. note::
:class:`SSLContext` is designed to be shared and used by multiple
connections.
Thus, it is thread-safe as long as it is not reconfigured after being
used by a connection.
:class:`SSLContext` objects have the following methods and attributes: :class:`SSLContext` objects have the following methods and attributes: