Repository navigation
Report WANT_WRITE from a blocked TLS 1.3 post-handshake auth response - #12014
yosuke-wolfssl wants to merge 1 commit into
Conversation
|
There was a problem hiding this comment.
🟡 Changes recommended
Without WOLFSSL_ASYNC_CRYPT, coalesced DTLS records can lose WANT_WRITE after CertificateRequest, allowing an ACK to overwrite the result or a NewSessionTicket to fail with OUT_OF_ORDER_E.
1 open issue
What changed in this PR
This PR updates wolfSSL’s TLS 1.3 and DTLS 1.3 post-handshake authentication handling so blocked responses report WANT_WRITE and can resume on a later read or write.
Changes:
- Preserve
WANT_WRITEinstead of converting it to a fatal authentication error. - Complete record bookkeeping and DTLS acknowledgment processing when a response blocks.
- Add regression tests for read/write retries and a second authentication request.
| File | Description |
|---|---|
tests/api/test_tls13.h |
Declares and registers the regression test. |
tests/api/test_tls13.c |
Tests blocked responses and retries for TLS and DTLS. |
src/tls13.c |
Preserves WANT_WRITE from authentication responses. |
src/internal.c |
Extends record completion handling to blocked responses. |
src/dtls13.c |
Acknowledges and marks requests processed before returning WANT_WRITE. |
Review effort: Balanced
df41376 to
8df7f18
Compare
|
@claude review |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12014
Scan targets checked: wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): tests/api/test_tls13.h
Coverage: 2 of 3 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_tls13.c
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
|
@claude review |
There was a problem hiding this comment.
🟡 Changes recommended
The regression test can pass without completed server-side PHA because WANT_READ and application-data exchange do not prove authentication success, so it needs explicit assertions for the peer certificate, peer verification, and Finished receipt.
1 open issue
1 resolved since last review
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12014
Scan targets checked: wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): tests/api/test_tls13.h
Coverage: 3 of 3 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
- DoTls13HandShakeMsgType() returns WANT_WRITE from the client's post-handshake auth wolfSSL_connect_TLSv13() call instead of POST_HAND_AUTH_ERROR for TLS only. - DoProcessReplyEx() finishes the CertificateRequest record for a WANT_WRITE as well as a WC_PENDING_E from that call - Add test_tls13_pha_want_write.
8df7f18 to
494f4e0
Compare

Problem
A TLS 1.3 client answers a post-handshake CertificateRequest from inside
wolfSSL_read(). When the socket will not take the Certificate / CertificateVerify / Finished flight, theWANT_WRITEis rewritten to the fatalPOST_HAND_AUTH_ERROR(-504):wolfSSL_negotiate()finishes the flight, then the next read fails withLENGTH_ERROR: the CertificateRequest record was left half-processedFix (
src/tls13.c)DoTls13HandShakeMsgType()passesWANT_WRITEfrom the post-handshakewolfSSL_connect_TLSv13()call through, as it already did forWC_PENDING_E.DoProcessReplyEx()(src/internal.c) finishes the CertificateRequest record forWANT_WRITEas well asWC_PENDING_E: it either resumes at the next message or skips the padding. This block was async-only before.The caller now sees
WOLFSSL_ERROR_WANT_WRITE, and the nextwolfSSL_read()orwolfSSL_write()finishes the flight throughwolfSSL_negotiate().Tests
test_tls13_pha_want_write: a blocked TLS 1.3 PHA response, retried once bywolfSSL_read()and once bywolfSSL_write(). The server must accept the certificate, and the client must then read the server's data.Verification
tls13.cor theinternal.cchange makes the test fail.--api, 0 failures:--enable-tls13 --enable-postauth --enable-sessioncerts(686 passed);--enable-all --enable-writedup --enable-asynccrypt --enable-asynccrypt-sw(2550 passed).Not in this PR
POST_HAND_AUTH_ERROR. Resuming it on DTLS also needs_Dtls13HandshakeRecv()to count the message as processed (Ack DTLS 1.3 handshake message when response hits WANT_WRITE #11768) andDoProcessReplyEx()to keepWANT_WRITEwhen more records follow in the same datagram. Follow-up.runProcessingOneMessagepath). The code was reviewed, but building that record needs a hand-crafted encrypted record.