Skip to content

Clarify TLS 1.3 behavior of the SSLContext PSK callbacks - #160159

Open
gpshead wants to merge 1 commit into
python:mainfrom
gpshead:docs-ssl-tls13-psk-cert-none
Open

gpshead wants to merge 1 commit into
python:mainfrom
gpshead:docs-ssl-tls13-psk-cert-none

Conversation

@gpshead

@gpshead gpshead commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Under TLS 1.3 a PSK is only an offer. The server can decline it and authenticate with a certificate instead, which the client then checks according to verify_mode (RFC 8446 section 2.2). OpenSSL documents the client side in SSL_CTX_set_psk_client_callback(3): if the callback supplies no PSK, "no PSK will be sent to the server but the handshake will continue".

The example and the PSK tests set CERT_NONE, so a client copied from them accepts any certificate-authenticated server under TLS 1.3. The docs now describe this, and the example and tests keep the CERT_REQUIRED default, which needs no CA certificates for a PSK handshake.

On the server side, "return a zero length PSK to reject the connection" only holds under TLS 1.3 if the server has no certificate. With one loaded, the handshake falls back to certificate authentication and session_reused is false, so the set_psk_server_callback() docs now say that too.

ANT-2026-2VE2XWXR

Under TLS 1.3 a PSK is only offered and may be declined, and both sides
fall back to certificate authentication when one is available, so
CERT_NONE leaves the server unauthenticated and a zero length PSK does
not reject the connection.  Drop CERT_NONE from the example and the PSK
tests.
@gpshead gpshead added docs Documentation in the Doc dir skip issue skip news topic-SSL needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 22, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Oct 22, 2026
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Oct 22, 2026
@gpshead gpshead self-assigned this Oct 22, 2026
@gpshead gpshead added the sprint label Oct 22, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Sprint Oct 22, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35313263 | 📁 Comparing 20080b8 against main (03864a2)

  🔍 Preview build  

1 file changed
± library/ssl.html

@gpshead
gpshead marked this pull request as ready for review October 22, 2026 03:51
@gpshead
gpshead requested a review from picnixz as a code owner October 22, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes skip issue skip news sprint tests Tests in the Lib/test dir topic-SSL

Projects

Status: Todo
Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants