Repository navigation
Add Mbed TLS client session tickets - #88
padelsbach wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Active issues allow buffered application data to bypass ticket notifications and can prevent TLS 1.2 session resumption when tickets are disabled during session import and re-enabled before the handshake.
2 open issues
What changed in this PR
Adds client session-ticket support to wolfPSA’s Mbed TLS compatibility layer for TLS 1.2 and TLS 1.3, while leaving server ticket support for a follow-up PR.
Changes:
- Adds TLS 1.2 ticket controls and TLS 1.3 ticket notifications, including Mbed TLS 3.6’s disabled-by-default signaling.
- Enables the required wolfSSL features and adds server API placeholders.
- Adds ticket and resumption tests, adjusts suite helpers, and documents compatibility limits.
| File | Description |
|---|---|
wolfpsa/mbedtls_compat/mbedtls/ssl.h |
Declares ticket APIs, constants, state, and server placeholders. |
user_settings.h |
Enables session tickets and ticket-age time support. |
tools/psa_want_probe.c |
Detects support for the session-ticket feature macro. |
test/mbedtls_compat/ssl_test.c |
Tests ticket controls, notifications, saving, and resumption. |
test/mbedtls_compat/ssl_suite/ssl_helpers_port.c |
Excludes unsupported server-ticket helpers for wolfPSA. |
test/mbedtls_compat/ssl_suite/cases.txt |
Clarifies that the ticket limitation concerns server tickets. |
test/mbedtls_compat/mbedtls3_test.c |
Tests Mbed TLS 3.6 signaling defaults and controls. |
src/mbedtls/ssl.c |
Implements client ticket handling and server placeholders. |
src/mbedtls/mbedtls3.c |
Implements the Mbed TLS 3.6 ticket-signaling setter. |
README.md |
Narrows the outstanding ticket feature to server support. |
docs/mbedtls-compatibility.md |
Documents ticket requirements, APIs, and known differences. |
Review effort: Balanced
| /* Ends the read for mbedtls_ssl_read() to return the ticket */ | ||
| if (s->reading && s->new_ticket) { | ||
| return WOLFSSL_CBIO_ERR_WANT_READ; |
There was a problem hiding this comment.
Read ahead requires WOLFSSL_TLS_READ_AHEAD and a call to wolfSSL_CTX_set_read_ahead. So this feature is not available to an application.
| if (ret == WOLFSSL_SUCCESS && | ||
| conf->session_tickets == MBEDTLS_SSL_SESSION_TICKETS_DISABLED && | ||
| !IsAtLeastTLSv1_3(ssl->session->version)) { | ||
| ret = wolfSSL_set_SessionTicket(ssl, NULL, 0); |
There was a problem hiding this comment.
Nice catch. Fixed.
For future reference, this is the problematic sequence:
- A connection with tickets on saves a session that has a ticket.
- The client turns tickets off, then calls mbedtls_ssl_set_session() with that session.
- The client turns tickets back on.
- The handshake should resume with the ticket, but it does a full handshake.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #88
Scan targets checked: wolfpsa-src, wolfpsa-bugs
Not reviewed (no scan target covers them): README.md, docs/mbedtls-compatibility.md, test/mbedtls_compat/ssl_suite/cases.txt, tools/psa_want_probe.c, user_settings.h
Coverage: 6 of 6 in-scope changed file(s) opened by the reviewer
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Max
| mbedtls_ssl_conf_session_tickets(&cli.conf, | ||
| MBEDTLS_SSL_SESSION_TICKETS_DISABLED); | ||
| } | ||
| ok = ok && Reconnect(&session) == (first && second); |
There was a problem hiding this comment.
Tls12TicketOff passes even if MbedSetTickets ignores MBEDTLS_SSL_SESSION_TICKETS_DISABLED · Weak or missing assertions
With first == 0, tickets stay disabled through Reconnect, so MbedSetSession deletes any ticket in the saved session, and the server cache is off. The test passes even if MbedSetTickets still requests a ticket in the first handshake, so the disabled branch goes untested.
Suggested fix: Add a case that disables tickets for the first handshake and re-enables them before Reconnect, expecting no resumption.
Basis: Mbed TLS ssl.h, mbedtls_ssl_conf_session_tickets(): enables or disables TLS 1.2 session tickets on the client, so a session from a handshake with tickets disabled holds no ticket to resume with.
Frauschi
left a comment
There was a problem hiding this comment.
Three small points below, the first optional.
| #if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C) | ||
| if (ssl->session_set && ssl->conf->session_tickets == | ||
| MBEDTLS_SSL_SESSION_TICKETS_DISABLED && | ||
| !IsAtLeastTLSv1_3(ssl->ssl->session->version)) { |
There was a problem hiding this comment.
Optional: no test runs TLS 1.3 with mbedtls_ssl_conf_session_tickets() off, so dropping this version check would still pass. A Tls13Ticket case with tickets disabled that still expects the signal and Reconnect() == 1 would cover it.
| { | ||
| (void)session; | ||
| (void)ticket_creation_time; | ||
| #ifdef WOLFPSA_MBEDTLS_3 |
There was a problem hiding this comment.
MBEDTLS_ERR_SSL_BAD_INPUT_DATA is PSA_ERROR_INVALID_ARGUMENT in every build (line 205), so both branches return the same value; drop the #ifdef and return it once.
|
|
||
| if (s->conf->signal_tickets && | ||
| wolfSSL_version(ssl) == MBEDTLS_SSL_VERSION_TLS1_3 && | ||
| wolfSSL_SESSION_get_ticket_lifetime_hint(session) > 0) { |
There was a problem hiding this comment.
A ticket with zero lifetime isn't signaled, but wolfSSL has already stored it over the previous ticket, so mbedtls_ssl_get_session() then returns a session that can't resume. Mbed TLS discards such a ticket; keep the earlier one or list this under the known differences.
There was a problem hiding this comment.
I believe MbedTLS and wolfPSA both discard the previous ticket and return failure until the next ticket. Docs updated with this.
There was a problem hiding this comment.
You're right, Mbed TLS frees the earlier ticket in ssl_tls13_parse_new_session_ticket too; the new doc note covers the difference.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #88
Scan targets checked: wolfpsa-src, wolfpsa-bugs
Not reviewed (no scan target covers them): README.md, docs/mbedtls-compatibility.md, test/mbedtls_compat/ssl_suite/cases.txt, tools/psa_want_probe.c, user_settings.h
Coverage: 2 of 3 in-scope changed file(s) opened by the reviewer; not opened: wolfpsa/mbedtls_compat/mbedtls/ssl.h
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
Fenrir's latest completed scan found no issues; clearing the prior automated change request.
Frauschi
left a comment
There was a problem hiding this comment.
All three comments resolved; verified locally, including the new TLS 1.3 tickets-off test.


Adds client session tickets for TLS 1.2 and 1.3, with
MBEDTLS_SSL_SESSION_TICKETS:mbedtls_ssl_conf_session_tickets, for TLS 1.2. Tickets are on by default. When off, the client sends no ticket, including one from a saved sessionmbedtls_ssl_readreturnsMBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKETfor each ticket, before the data after it, andmbedtls_ssl_get_sessionthen has the ticket. A ticket with no lifetime is not signaledmbedtls_ssl_conf_tls13_enable_signal_new_session_tickets, withWOLFPSA_MBEDTLS_3. As in Mbed TLS 3.6,mbedtls_ssl_config_defaultsturns the signal offmbedtls_ssl_conf_session_tickets_cb,mbedtls_ssl_conf_new_session_ticketsandmbedtls_ssl_session_get_ticket_creation_timeare placeholders so server code builds. A server sends no tickets until a follow-up PR adds server ticketsuser_settings.hnow definesHAVE_SESSION_TICKET, andHAVE_SYS_TIME_Hfor the ticket's age.