Do not report completion while a 0-RTT client is in early data - #21
Merged
Conversation
Motivation: A client that offers 0-RTT early data (Resumption.offerEarlyData) reaches SSL_do_handshake == 1 as soon as it may send early data, while SSL_in_early_data() is still true and the handshake has not completed: the server confirms or rejects the 0-RTT in its response (RFC 9001 section 4.6.1). advance() treated that first 1 as State.complete, so a client reported the handshake done before it had consumed the server's confirmation. A driver that stops advancing on .complete then never learns whether its 0-RTT was accepted, and SSL_early_data_accepted stays false. Diagnosed downstream in swift-nio-quic, where a resumed 0-RTT handshake reused the session at 1-RTT but never registered the early-data acceptance the server had actually granted. Modifications: advance() checks SSL_in_early_data() when SSL_do_handshake returns 1: while the client is in the early-data state it reports .wantsMoreData — the handshake is still in flight — reaching .complete only once the client has left early data. Non-early-data handshakes are unaffected, since SSL_in_early_data() is always false for them. Validated by testOfferedEarlyDataStaysInHandshakeUntilConfirmed (an offering client's first advance() is .wantsMoreData, not .complete); the existing testOfferedEarlyDataIsAccepted and the rest of the QUIC handshake suite still pass. Result: A 0-RTT-offering client stays in the handshake until the server resolves its early data, so earlyDataAccepted reflects the server's decision. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cu2dW2zXuAnwDRaiHr7feR
ydnar
marked this pull request as ready for review
July 2, 2026 21:47
ydnar
pushed a commit
to alta/swift-nio-quic
that referenced
this pull request
Jul 2, 2026
Bump the swift-nio-ssl fork pin to its `main` after alta/swift-nio-ssl#21, which stops a 0-RTT-offering client from reporting handshake completion while it is still in the early-data window (RFC 9001 § 4.6.1). Before the fix, a resumed client that offered early data reported `.complete` from its first advance, so the driver stopped short and never consumed the server's acceptance. With the fix, a resumed client that offers early data and a server that accepts it agree end to end, verified by the new `TLSHandshakeTests.acceptsOfferedEarlyData`: both report `earlyDataAccepted` and the client is not rejected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cu2dW2zXuAnwDRaiHr7feR
This was referenced Jul 2, 2026
ydnar
added a commit
that referenced
this pull request
Jul 17, 2026
Motivation: A client that offers 0-RTT early data (Resumption.offerEarlyData) reaches SSL_do_handshake == 1 as soon as it may send early data, while SSL_in_early_data() is still true and the handshake has not completed: the server confirms or rejects the 0-RTT in its response (RFC 9001 section 4.6.1). advance() treated that first 1 as State.complete, so a client reported the handshake done before it had consumed the server's confirmation. A driver that stops advancing on .complete then never learns whether its 0-RTT was accepted, and SSL_early_data_accepted stays false. Diagnosed downstream in swift-nio-quic, where a resumed 0-RTT handshake reused the session at 1-RTT but never registered the early-data acceptance the server had actually granted. Modifications: advance() checks SSL_in_early_data() when SSL_do_handshake returns 1: while the client is in the early-data state it reports .wantsMoreData — the handshake is still in flight — reaching .complete only once the client has left early data. Non-early-data handshakes are unaffected, since SSL_in_early_data() is always false for them. Validated by testOfferedEarlyDataStaysInHandshakeUntilConfirmed (an offering client's first advance() is .wantsMoreData, not .complete); the existing testOfferedEarlyDataIsAccepted and the rest of the QUIC handshake suite still pass. Result: A 0-RTT-offering client stays in the handshake until the server resolves its early data, so earlyDataAccepted reflects the server's decision. Claude-Session: https://claude.ai/code/session_01Cu2dW2zXuAnwDRaiHr7feR Co-authored-by: Claude <noreply@anthropic.com>
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.
Motivation:
A client that offers 0-RTT early data (
Resumption.offerEarlyData) reachesSSL_do_handshake == 1as soon as it may send early data, whileSSL_in_early_data()is still true and the handshake has not completed — the server confirms or rejects the 0-RTT in its response (RFC 9001 § 4.6.1).advance()treated that first1asState.complete, so a client reported the handshake done before it had consumed the server's confirmation. A driver that stops advancing on.completethen never learns whether its 0-RTT was accepted, andSSL_early_data_acceptedstays false. Diagnosed downstream in swift-nio-quic, where a resumed 0-RTT handshake reused the session at 1-RTT but never registered the early-data acceptance the server had actually granted (the#20test masked it because its pump keeps advancing past the premature.complete).Modifications:
advance()checksSSL_in_early_data()whenSSL_do_handshakereturns1: while the client is in the early-data state it reports.wantsMoreData— the handshake is still in flight — reaching.completeonly once the client has left early data. Non-early-data handshakes are unaffected, sinceSSL_in_early_data()is always false for them.Validated by
testOfferedEarlyDataStaysInHandshakeUntilConfirmed(an offering client's firstadvance()is.wantsMoreData, not.complete); the existingtestOfferedEarlyDataIsAcceptedand the rest of the QUIC handshake suite still pass.Result:
A 0-RTT-offering client stays in the handshake until the server resolves its early data, so
earlyDataAcceptedreflects the server's decision.🤖 Generated with Claude Code
Generated by Claude Code