Commit c6c39e4
authored
quic: add TLS session ticket resumption support (#42734)
Commit Message: quic: add session ticket resumption support using
configured session ticket keys
Additional Description:
## Summary
TLS session resumption is essential for QUIC performance. Without it,
every connection requires a full TLS handshake, and 0-RTT becomes
meaningless since there's no session state to resume from. As noted in
#42682, TLS-related data accounts for roughly 1/3 of bytes during
connection establishment - session resumption eliminates most of this
overhead.
Currently, Envoy's QUIC implementation does not support session
resumption across workers or processes. While users can configure
`session_ticket_keys` or `session_ticket_keys_sds_secret_config` in
downstream TLS context, these settings have no effect on QUIC
connections. This limitation is documented in #25418, which explicitly
states that session ticket key plumbing is missing from the QUIC
implementation.
This PR bridges that gap by enabling QUIC to use the same session ticket
keys configured for TCP TLS, allowing session resumption to work across
workers and processes.
## Implementation
We subclass QUICHE's `TlsServerHandshaker` as `EnvoyTlsServerHandshaker`
and install a session-ticket key callback on the shared QUICHE
`SSL_CTX`. The callback reuses
`ServerContextImpl::sessionTicketProcess()` so QUIC and TCP TLS share
identical session-ticket handling (same keys, same format, same rotation
semantics).
**Key design decisions:**
1. **Per-connection pinning of `ServerContextImpl`**: Each
`EnvoyTlsServerHandshaker` holds a `ServerContextSharedPtr` captured at
connection creation, and stores `this` in SSL ex_data. The static ticket
callback retrieves the handshaker from ex_data and delegates to the
pinned context's `sessionTicketProcess()`. Because the shared pointer
keeps the context alive, an SDS update that rotates the factory's active
context does not invalidate in-flight connections — matching TCP TLS
behavior where each connection is bound to the `ServerContextImpl`
active at connection creation.
2. **`SSL_CTX_set_tlsext_ticket_key_cb` over
`SSL_CTX_set_ticket_aead_method`**: We use the same callback mechanism
as TCP TLS rather than QUICHE's `TicketCrypter` interface, so
`ServerContextImpl::sessionTicketProcess()` can be reused unchanged.
3. **Graceful fallback**: If the runtime guard is toggled between
`OnNewSslCtx` (which installs the callback on the shared `SSL_CTX`) and
connection creation (which may fall back to the vanilla handshaker), the
ticket callback finds a null handshaker in ex_data and returns 0 to skip
ticket issuance for that connection rather than crashing.
## Flow
```
Server startup (once per SSL_CTX):
EnvoyQuicProofSource::OnNewSslCtx()
└─ if runtime flag on:
SSL_CTX_set_tlsext_ticket_key_cb(ssl_ctx, EnvoyTlsServerHandshaker::ticketKeyCallback)
Per connection:
EnvoyQuicCryptoServerStreamFactoryImpl::createEnvoyQuicCryptoServerStream()
└─ reads SessionTicketConfig from QuicServerTransportSocketFactory
└─ constructs EnvoyTlsServerHandshaker(session, crypto_config, factory.sslCtx(), disable_resumption)
└─ pins ServerContextSharedPtr
└─ SSL_set_ex_data(ssl, handshakerExDataIndex(), this)
└─ if disable_resumption || no ticket keys: DisableResumption() // SSL_OP_NO_TICKET
During handshake (BoringSSL-driven):
ticketKeyCallback(ssl, ...)
└─ handshaker = SSL_get_ex_data(ssl, handshakerExDataIndex())
└─ if null: return 0 // guard toggled after OnNewSslCtx — skip ticket
└─ return handshaker->pinnedServerContext()->sessionTicketProcess(ssl, ...)
```
Risk Level: Low (behind runtime guard, disabled by default)
Testing: New unit tests for `EnvoyTlsServerHandshaker` and
`EnvoyQuicProofSource`; new integration coverage in
`sds_dynamic_integration_test` (`SessionTicketKeysViaSds`,
`SessionTicketKeysRemovedViaSds`) and in `quic_http_integration_test`
(`SessionTicketResumptionWithStaticKeys`,
`NoSessionTicketResumptionWithoutKeys`).
Docs Changes: N/A
Release Notes: Added
Platform Specific Features: N/A
[Optional Runtime guard:]
`envoy.reloadable_features.quic_session_ticket_support` (default: false)
[Optional Fixes #Issue] Partially addresses #25418
---------
Signed-off-by: Doogie Min <doogie.min@sendbird.com>1 parent 7ea91de commit c6c39e4
18 files changed
Lines changed: 504 additions & 11 deletions
File tree
- changelogs
- source
- common
- quic
- runtime
- tls
- extensions/quic/crypto_stream
- test
- common/quic
- integration
- tools/spelling
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
99 | 106 | | |
100 | 107 | | |
101 | 108 | | |
| |||
104 | 111 | | |
105 | 112 | | |
106 | 113 | | |
107 | | - | |
108 | 114 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
125 | 138 | | |
126 | 139 | | |
127 | 140 | | |
| |||
130 | 143 | | |
131 | 144 | | |
132 | 145 | | |
| 146 | + | |
133 | 147 | | |
134 | 148 | | |
135 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
116 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
117 | 124 | | |
118 | 125 | | |
119 | 126 | | |
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
41 | 69 | | |
42 | 70 | | |
43 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
| |||
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
85 | | - | |
86 | | - | |
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
0 commit comments