-
Notifications
You must be signed in to change notification settings - Fork 5.3k
quic: add TLS session ticket resumption support #42734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bellatoris
wants to merge
36
commits into
envoyproxy:main
Choose a base branch
from
bellatoris:doogie/quic-proof-source-update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 33 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
4a0cf75
quic: add TLS session ticket resumption support
bellatoris d368288
fix: format issues
bellatoris c19d430
Resolve merge conflict in changelogs/current.yaml
bellatoris 52cd01c
merge main
bellatoris a290a7e
merge main
bellatoris 9295202
merge upstream/main
bellatoris 2631e06
Address review comments and fix QUICHE API compatibility
bellatoris 8060975
Merge remote-tracking branch 'upstream/main' into doogie/quic-proof-s…
bellatoris 81ea972
fix: add 'codepoint' to spelling dictionary
bellatoris 2123532
test: add coverage tests for QUIC session ticket resumption
bellatoris 6231e2c
test: add coverage tests for QUIC session ticket resumption
bellatoris 5c6f897
test: extract ticketKeyCallback for testability and add callback cove…
bellatoris fccf79f
test: add old GetCertChain API path coverage for handshaker SelectCer…
bellatoris e660c96
refactor: eliminate custom EnvoyTlsServerHandshaker, use QUICHE default
bellatoris 4a17b26
Merge upstream main
bellatoris c1b2de5
fix: spelling check error in dispatcher test comment
bellatoris ce520ef
address review: use transport_socket_factory directly, remove filter_…
bellatoris 8ff74e4
Merge upstream main
bellatoris f1e4cc3
address review: ENVOY_BUG for null factory, rename test, replace semi…
bellatoris e852b81
fix: guard against empty session ticket keys in processSessionTicket
bellatoris 54c118d
fix: use inline_bytes for session ticket key in integration test
bellatoris 538e8dc
test: add SDS session ticket integration tests
bellatoris b32b0ea
Merge branch 'main' into doogie/quic-proof-source-update
bellatoris e3203f7
Merge branch 'main' into doogie/quic-proof-source-update
bellatoris 0768977
Merge branch 'main' into doogie/quic-proof-source-update
bellatoris f3150bc
refactor: consolidate session ticket logic into EnvoyTlsServerHandshaker
bellatoris f36f4ba
fix: spelling check - remove tlsext from comment
bellatoris f692b02
fix: spelling check - avoid BoringSSL type names in comments
bellatoris 3455bd0
Merge branch 'main' into doogie/quic-proof-source-update
bellatoris 200d459
Merge branch 'main' into doogie/quic-proof-source-update
bellatoris 36bb344
fix: address review comments (comment clarifications + test cleanup)
bellatoris 14eff46
fix: spelling check - avoid QUICHE's possessive in comment
bellatoris 8349fe1
Merge branch 'main' into doogie/quic-proof-source-update
bellatoris bba7a8f
Merge branch 'main' into doogie/quic-proof-source-update
bellatoris 3e26bc9
Merge branch 'main' into doogie/quic-proof-source-update
bellatoris d7a87e4
Merge branch 'main' into doogie/quic-proof-source-update
bellatoris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #include "source/common/quic/envoy_tls_server_handshaker.h" | ||
|
|
||
| #include "source/common/common/macros.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Quic { | ||
|
|
||
| EnvoyTlsServerHandshaker::EnvoyTlsServerHandshaker( | ||
| quic::QuicSession* session, const quic::QuicCryptoServerConfig* crypto_config, | ||
| Ssl::ServerContextSharedPtr pinned_ssl_ctx, bool disable_resumption) | ||
| : TlsServerHandshaker(session, crypto_config), pinned_ssl_ctx_(std::move(pinned_ssl_ctx)) { | ||
| SSL_set_ex_data(ssl(), handshakerExDataIndex(), this); | ||
| // Also check the pinned context for keys: the factory is shared across workers and | ||
| // config_ may reflect an SDS update before ssl_ctx_ is swapped on the main thread. | ||
| if (disable_resumption || !pinnedServerContext()->hasSessionTicketKeys()) { | ||
| DisableResumption(); | ||
| } | ||
| } | ||
|
|
||
| int EnvoyTlsServerHandshaker::handshakerExDataIndex() { | ||
| CONSTRUCT_ON_FIRST_USE(int, []() -> int { | ||
| int index = SSL_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr); | ||
| RELEASE_ASSERT(index >= 0, "Failed to allocate SSL ex_data index for handshaker"); | ||
| return index; | ||
| }()); | ||
| } | ||
|
|
||
| int EnvoyTlsServerHandshaker::ticketKeyCallback(SSL* ssl, uint8_t* key_name, uint8_t* iv, | ||
| EVP_CIPHER_CTX* ctx, HMAC_CTX* hmac_ctx, | ||
| int encrypt) { | ||
| auto* handshaker = | ||
| static_cast<EnvoyTlsServerHandshaker*>(SSL_get_ex_data(ssl, handshakerExDataIndex())); | ||
| if (handshaker == nullptr || handshaker->pinnedServerContext() == nullptr) { | ||
| // Null handshaker can occur if the runtime guard was toggled between | ||
| // OnNewSslCtx (which installed this callback on the SSL_CTX) and | ||
| // connection creation (which fell back to the vanilla TlsServerHandshaker). | ||
| // Return 0 to disable ticket for this connection — graceful fallback. | ||
| return 0; | ||
| } | ||
| return handshaker->pinnedServerContext()->sessionTicketProcess(ssl, key_name, iv, ctx, hmac_ctx, | ||
| encrypt); | ||
| } | ||
|
|
||
| } // namespace Quic | ||
| } // namespace Envoy |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #pragma once | ||
|
|
||
| #include <openssl/ssl.h> | ||
|
|
||
| #include "source/common/common/assert.h" | ||
| #include "source/common/tls/server_context_impl.h" | ||
|
|
||
| #include "quiche/quic/core/tls_server_handshaker.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Quic { | ||
|
|
||
| // TlsServerHandshaker subclass for QUIC session ticket handling. | ||
| // | ||
| // The session ticket key callback is installed on the shared QUICHE ssl | ||
| // context, so every connection reaches the same callback regardless of which | ||
| // filter chain served it. To find the right session ticket keys at callback | ||
| // time, each connection pins a shared pointer to its ServerContextImpl in | ||
| // ssl ex data at creation time. The pinned pointer keeps the context alive | ||
| // for the connection even after an SDS update rotates the factory's active | ||
| // context, and it matches TCP TLS behavior where each connection is bound | ||
| // to the ServerContextImpl that was current at connection creation. | ||
| class EnvoyTlsServerHandshaker : public quic::TlsServerHandshaker { | ||
| public: | ||
| EnvoyTlsServerHandshaker(quic::QuicSession* session, | ||
| const quic::QuicCryptoServerConfig* crypto_config, | ||
| Ssl::ServerContextSharedPtr pinned_ssl_ctx, bool disable_resumption); | ||
|
|
||
| // Session ticket key callback installed on the QUICHE ssl context. | ||
| // Retrieves the handshaker from ssl ex_data and delegates to the pinned | ||
| // ServerContextImpl::sessionTicketProcess(). | ||
| static int ticketKeyCallback(SSL* ssl, uint8_t* key_name, uint8_t* iv, EVP_CIPHER_CTX* ctx, | ||
| HMAC_CTX* hmac_ctx, int encrypt); | ||
|
|
||
| // SSL ex_data index for storing the handshaker pointer per-connection. | ||
| static int handshakerExDataIndex(); | ||
|
|
||
| private: | ||
| // QuicServerTransportSocketFactory always creates ServerContextImpl, | ||
| // so this downcast is safe for all QUIC connections. | ||
| Extensions::TransportSockets::Tls::ServerContextImpl* pinnedServerContext() const { | ||
| return static_cast<Extensions::TransportSockets::Tls::ServerContextImpl*>( | ||
| pinned_ssl_ctx_.get()); | ||
| } | ||
|
|
||
| Ssl::ServerContextSharedPtr pinned_ssl_ctx_; | ||
| }; | ||
|
|
||
| } // namespace Quic | ||
| } // namespace Envoy |
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.