Skip to content

Cache TLS 1.2 client sessions only after the server Finished verifies - #11393

Open
gasbytes wants to merge 1 commit into
wolfSSL:masterfrom
gasbytes:session-ticket-cache-fix
Open

Cache TLS 1.2 client sessions only after the server Finished verifies#11393
gasbytes wants to merge 1 commit into
wolfSSL:masterfrom
gasbytes:session-ticket-cache-fix

Conversation

@gasbytes

@gasbytes gasbytes commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Description

The client cached its session and ticket before verifying the server Finished,
so a failed handshake left a resumable session behind (RFC 5246 Section 7.2.2).
Caching moves to DoFinished(); the server path is unchanged.

Testing

Added three regression tests to also cover the edge cases: ticket dropped on a bad Finished, cached after a good one, and preserved across a resumption with an empty NewSessionTicket.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new “drop ticket” path on Finished verification failure clears logical state but can retain dynamically allocated ticket buffers, which can unnecessarily hold memory after a failed handshake.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes TLS 1.2 client session-ticket caching semantics so that a client session/ticket is only cached after the server Finished has been verified, preventing resumable sessions from being left behind after failed handshakes (per RFC 5246 §7.2.2).

Changes:

  • Move TLS 1.2 client session caching to DoFinished() (post server-Finished verification); keep server caching behavior in SendFinished().
  • Clear unverified session tickets when Finished verification fails.
  • Add regression tests covering: bad Finished dropping tickets, successful Finished caching, and empty-renewal tickets preserving cached entries.
File summaries
File Description
tests/api/test_tls.h Registers three new TLS 1.2 session-ticket caching regression tests in the API test suite.
tests/api/test_tls.c Implements regression tests for caching only after verified Finished and for preserving/dropping tickets in edge cases.
src/internal.c Shifts client-side caching to post-Finished verification, drops unverified tickets on Finished failure, and avoids caching on empty ticket renewals.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/internal.c
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m3

  • FLASH: .text +16 B (+0.0%, 125,763 B / 262,144 B, total: 48% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .text +128 B (+0.0%, 783,004 B / 1,048,576 B, total: 75% used)

gcc-arm-cortex-m4-pq

  • FLASH: .text +64 B (+0.0%, 301,704 B / 1,048,576 B, total: 29% used)

gcc-arm-cortex-m4-rsa-only

  • FLASH: .text +192 B (+0.1%, 332,576 B / 1,048,576 B, total: 32% used)

gcc-arm-cortex-m4-tls13

  • FLASH: .text +64 B (+0.0%, 242,191 B / 262,144 B, total: 92% used)

gcc-arm-cortex-m7-pq

  • FLASH: .text +64 B (+0.0%, 302,600 B / 1,048,576 B, total: 29% used)

gcc-arm-cortex-m7-tls13

…es, so a handshake that fails leaves nothing resumable in the cache

RFC 5246 Section 7.2.2
@gasbytes
gasbytes force-pushed the session-ticket-cache-fix branch from 46defbd to 83c6bed Compare September 7, 2026 15:22
@gasbytes gasbytes assigned rizlik and unassigned gasbytes Sep 7, 2026
@gasbytes
gasbytes requested a review from rizlik September 7, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants