enh(NetSSL_OpenSSL): TLS 1.3 session resumption when session cache is enabled #5414 - #5417
Open
matejk wants to merge 2 commits into
Open
enh(NetSSL_OpenSSL): TLS 1.3 session resumption when session cache is enabled #5414#5417matejk wants to merge 2 commits into
matejk wants to merge 2 commits into
Conversation
…he first write Requesting it right after the handshake leaves the connection in the handshake state, which makes a shutdown without any data transfer fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5414.
SecureSocketImpl::acceptSSL()disabled TLS 1.3 session tickets unconditionally,so a POCO server could not offer TLS 1.3 session resumption at all. That call was
added for #2776: a TLS 1.3 server writes its tickets at handshake completion, and
if the client sends its data and closes without reading, the write fails with
EPIPE and the handshake is reported as failed even though the peer completed it.
Removing the call, as suggested in the issue, would reintroduce #2776 -- current
OpenSSL still sends tickets at handshake completion by default. Instead, tickets
become opt-in through the existing
Context::enableSessionCache().Changes
is enabled on a server context, one ticket is requested with
SSL_new_session_ticket()immediately before the first application data write,so it goes out with that data and the EPIPE window never opens.
suppressed only when the session cache is disabled.
acceptSSL()now reports "Cannot disable session tickets" instead of thecopy-pasted "Cannot create SSL object", and frees the SSL object on that path,
consistent with
connectSSL().The ticket is requested before the write rather than at handshake completion
because
SSL_new_session_ticket()puts the connection back into the handshakestate until the ticket is written, and
SSL_shutdown()fails in that state("shutdown while in init"). Requesting it before the write that immediately
flushes it keeps that state from outliving a single call, and also means a
repeated
completeHandshake()call cannot queue redundant tickets.Behaviour
Default behaviour is unchanged on all OpenSSL versions:
Context::init()setsSSL_SESS_CACHE_OFFandSSLManagerdefaultscacheSessionsto false, sotickets stay suppressed unless an application opts in.
Two consequences are documented in
Context::enableSessionCache():ticket, so its sessions cannot be resumed.
and with them the Shutdown TLS1.3 connection #2776 failure mode.
A ticket can be used for one resumption only, so a client that resumes
repeatedly has to take a new session from each connection instead of reusing the
first one.
FTPSClientSessiondoes not do that yet -- it always takes thesession from the control connection -- so
forceSessionReusestill fails fromthe second data connection on. That is a separate client-side change.
Tests
TCPServerTestgains four cases:testReuseSessionTLS13-- session cache enabled: the session is resumable andis reused on reconnect. Verified to fail without the change.
testNoSessionTicketsTLS13-- session cache disabled: no ticket, no reuse.testClientClosesWithoutReadingTLS13-- the Shutdown TLS1.3 connection #2776 scenario with the sessioncache enabled: the client sends and closes without reading, the server-side
handshake still succeeds and the data arrives.
testShutdownWithoutDataTLS13-- the server completes the handshake and shutsdown without transferring data. Verified to fail if the ticket is requested at
handshake completion instead of before the write.
Full NetSSL suite passes on macOS and Linux (OpenSSL 3.5.3); the two
testProxyerrors are pre-existing and need an external proxy.