Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
4 tasks
A server marked with apisix_ssl_session_ticket_takeover, in http or in stream, hands the session ticket keys of its SSL_CTX over to Lua: the context encrypts and decrypts tickets with a complete, ordered set of keys installed through resty.apisix.ssl_session_ticket, the first key issuing and every key decrypting, so that the servers of several nodes that install the same set resume each other's sessions. Servers that are not marked, the Admin API among them, keep the native keys, including those nginx rotates in a session cache they share with a marked server. - patch/1.31.1.1: both SSL merge paths bind the mark to the new SSL_CTX, and ngx_ssl_session_ticket_keys() registers the module's callback for a marked context before the return it takes without a shared session cache, the stream default - a marked context starts with SSL_OP_NO_TICKET whatever ssl_session_tickets says, tickets only go on with a complete set, and the callback refuses the keys once the context is off or has none: never a fallback to keys of OpenSSL's own - the registration leaves a record of the context and of the configuration generation in the SSL_CTX ex_data, which the FFI checks, as OpenSSL has no getter for the callback - sync_connection() aligns the options a connection copied at accept with its context, from ssl_client_hello_by_lua* - resty.apisix.process gets the configuration generation of the process and an identity with a slot bounded per generation, to key per-process records across reloads without the pid - the takeover is locked to nginx 1.31.1 at compile time; the other bundles build without it and report it as not supported Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
membphis
force-pushed
the
feat/ssl-session-ticket-takeover
branch
from
October 27, 2026 10:27
3593285 to
3ac75a1
Compare
2 tasks
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.
What
A server marked with the new
apisix_ssl_session_ticket_takeoverdirective, inhttpor instream, hands the TLS session ticket keys of itsSSL_CTXover to Lua. The context then encrypts and decrypts tickets with a complete, ordered set of keys installed through the newresty.apisix.ssl_session_ticketmodule: the first key issues tickets, every key decrypts. Servers of several nodes that install the same set resume each other's sessions, over TLSv1.2 and TLSv1.3.Servers that are not marked keep the native behavior, including the keys nginx rotates in an
ssl_session_cachethey share with a marked server (the Admin API sharesshared:SSLwith the data plane in APISIX).resty.apisix.processalso gets the configuration generation of the process and an identity with a slot bounded per generation, so per-process records can be keyed across reloads without the pid.How
patch/1.31.1.1/nginx-ssl_session_ticket_takeover.patch: both the http and the stream SSL merge paths bind the server's mark to theSSL_CTXthey just created, right beforengx_ssl_session_ticket_keys(); that function registers the module's callback for a marked context before the return it takes when there is neitherssl_session_ticket_keynor a shared session cache, which is the stream default. Unmarked contexts keep the native path untouched.server{}, so a mark is never inherited fromhttp{}/stream{}; each stream server is marked on its own. It cannot be combined withssl_session_ticket_key.SSL_OP_NO_TICKETwhateverssl_session_ticketssays. Tickets only go on through the API, with a complete set installed; a failed registration keeps the context off. The callback refuses the keys whenever the context is off or has none (decrypt returns 0: a full handshake; encrypt returns 0: an empty ticket in TLSv1.2, none in TLSv1.3), so it never falls back to keys OpenSSL makes up. Renewal follows nginx: always in TLSv1.3, else for a non-default key. The return values were checked against the OpenSSL 3.5.9 sources.SSL_CTXex_data;contexts()reports whether it verifies, and keys cannot be installed nor tickets turned on otherwise.SSL_new()copies the options of the context at accept, sosync_connection()alignsSSL_OP_NO_TICKETof the current connection with its context, meant forssl_client_hello_by_lua*.set_keys()thenenable_tickets(); off =disable_tickets()thenrevoke_keys(). Nothing closes a connection, andnum_ticketsis never touched: when off, TLSv1.3 still sends its stateful tickets.#error), rather than relying on the patch failing to apply. Other bundles, such as the api7ee-runtime one, build as before: the directive only warns and the API reportsnot_supported.The directive and both Lua APIs are documented in the README.
Tests
New Test::Nginx files, which only run on OpenResty 1.31.1 (the only bundle with the patch) and skip elsewhere:
t/ssl-session-ticket.t(http) andt/stream/ssl-session-ticket.t(stream, servers without a session cache): real resumption between two contexts standing for two nodes, checked with$ssl_session_reusedand the key name in the client's ticket; first key issues, older keys decrypt, reorder, removal;0 -> n -> 0with an open connection; callback results 1, renew, 0 and negative; a context turned off mid-handshake; connection alignment when the client hello is delayed; unmarked servers keep the native keys; off semantics per protocol; directive placement and API errors.t/ssl-session-ticket-unregistered.t: a failed callback registration is visible and keeps the context off.t/ssl-session-ticket-reload.t: the generation moves on with a reload, with the registrations; worker and privileged agent identities.t/process.t: generation and identity of a single process.The negative callback results and the failed registration cannot be caused from outside: builds
--with-debug(as in CI) let the tests provoke them through environment variables; other builds do not contain that code.Local verification: an apisix-runtime built with this branch and the CI compiler flags (
-fsanitize=address -Werror, OpenResty 1.31.1.1, OpenSSL 3.5.9) passes everyt/file run by the apisix-runtime CI jobs,t/gm.tskipping without Tongsuo as in CI. OpenResty 1.21.4.4 with this branch (no takeover patch) also builds with the same flags and reports the takeover as not supported.luacheckwas not run locally.Draft: the Lua API is still being reviewed before this is marked ready.
🤖 Generated with Claude Code