Skip to content

Commit 2002e4b

Browse files
committed
Document more TLS 1.3 PSK fallback cases in the ssl docs
A callback that raises is treated like one returning a zero length PSK, so under TLS 1.3 it also falls back to certificate authentication. A server with a certificate loaded declines even a matching PSK with OpenSSL's default TLS 1.3 cipher suite order, which selects a SHA-384 suite. Mention checking session_reused as the client side alternative to not using CERT_NONE.
1 parent 20080b8 commit 2002e4b

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

‎Doc/library/ssl.rst‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,12 +2246,13 @@ to speed up repeated connections from the same clients.
22462246
- the PSK is only offered to the server, which may decline it and
22472247
authenticate with a certificate instead. That certificate is checked
22482248
according to :attr:`~SSLContext.verify_mode`, so a client relying on
2249-
the PSK to authenticate the server must not set it to
2250-
:const:`CERT_NONE`. A PSK handshake does not need any CA
2251-
certificates to be loaded when using :const:`CERT_REQUIRED`.
2252-
:attr:`SSLSocket.session_reused` is true if the PSK was used.
2249+
the PSK to authenticate the server should not set it to
2250+
:const:`CERT_NONE`, or should check :attr:`SSLSocket.session_reused`,
2251+
which is true if the PSK was used. A PSK handshake does not need any
2252+
CA certificates to be loaded when using :const:`CERT_REQUIRED`.
22532253
- a zero length PSK does not reject the connection, it only means that
2254-
no PSK is offered.
2254+
no PSK is offered. An exception raised by the callback has the same
2255+
effect.
22552256
- the PSK is used with the SHA-256 handshake digest, so a server can
22562257
only accept it with a cipher suite that uses SHA-256.
22572258

@@ -2302,12 +2303,16 @@ to speed up repeated connections from the same clients.
23022303
When using TLS 1.3:
23032304

23042305
- the ``identity_hint`` parameter is not sent to the client.
2305-
- a zero length PSK only declines the client's PSK. If a certificate
2306-
was loaded with :meth:`~SSLContext.load_cert_chain`, the handshake
2307-
continues with certificate authentication instead of failing, so a
2308-
server relying on the PSK to authenticate clients should not load one,
2309-
or should check :attr:`SSLSocket.session_reused`, which is true if the
2310-
PSK was used.
2306+
- a zero length PSK, or an exception raised by the callback, only
2307+
declines the client's PSK. If a certificate was loaded with
2308+
:meth:`~SSLContext.load_cert_chain`, the handshake continues with
2309+
certificate authentication instead of failing, so a server relying on
2310+
the PSK to authenticate clients should not load one, or should check
2311+
:attr:`SSLSocket.session_reused`, which is true if the PSK was used.
2312+
- the PSK can only be accepted with a cipher suite that uses SHA-256.
2313+
When a certificate is loaded, OpenSSL's default TLS 1.3 cipher suite
2314+
order selects a SHA-384 suite instead, so the PSK is declined even if
2315+
it matches.
23112316

23122317
Example usage::
23132318

0 commit comments

Comments
 (0)