-
Notifications
You must be signed in to change notification settings - Fork 5.5k
quic: use sds for upstream http/3 #16462
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,19 +19,34 @@ getContext(Network::TransportSocketFactory& transport_socket_factory) { | |
| auto* quic_socket_factory = | ||
| dynamic_cast<QuicClientTransportSocketFactory*>(&transport_socket_factory); | ||
| ASSERT(quic_socket_factory != nullptr); | ||
| ASSERT(quic_socket_factory->sslCtx() != nullptr); | ||
| return quic_socket_factory->sslCtx(); | ||
| } | ||
|
|
||
| std::shared_ptr<quic::QuicCryptoClientConfig> PersistentQuicInfoImpl::cryptoConfig() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is somewhat laid-back updating. If a client connection is created before the SSL context update, will its crypto config not be updated till another createQuicNetworkConnection() is called?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think once a quic client is created we support reloading, so AFIK it'd only be applied when we created a new client anyway.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ACK.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would think if we changed client certs we'd not want to keep resumption info? cc @RyanTheOptimist
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, that sounds right to me. |
||
| auto context = getContext(transport_socket_factory_); | ||
| // If the secrets haven't been loaded, there is no crypto config. | ||
| if (context == nullptr) { | ||
| return nullptr; | ||
| } | ||
|
|
||
| // If the secret has been updated, update the proof source. | ||
| if (context.get() != client_context_.get()) { | ||
| client_context_ = context; | ||
| client_config_ = std::make_shared<quic::QuicCryptoClientConfig>( | ||
| std::make_unique<EnvoyQuicProofVerifier>(getContext(transport_socket_factory_)), | ||
| std::make_unique<EnvoyQuicSessionCache>((time_source_))); | ||
| } | ||
| // Return the latest client config. | ||
| return client_config_; | ||
| } | ||
|
|
||
| PersistentQuicInfoImpl::PersistentQuicInfoImpl( | ||
| Event::Dispatcher& dispatcher, Network::TransportSocketFactory& transport_socket_factory, | ||
| TimeSource& time_source, Network::Address::InstanceConstSharedPtr server_addr) | ||
| : conn_helper_(dispatcher), alarm_factory_(dispatcher, *conn_helper_.GetClock()), | ||
| server_id_{getConfig(transport_socket_factory).serverNameIndication(), | ||
| static_cast<uint16_t>(server_addr->ip()->port()), false}, | ||
| crypto_config_(std::make_unique<quic::QuicCryptoClientConfig>( | ||
| std::make_unique<EnvoyQuicProofVerifier>(getContext(transport_socket_factory)), | ||
| std::make_unique<EnvoyQuicSessionCache>(time_source))) { | ||
| transport_socket_factory_(transport_socket_factory), time_source_(time_source) { | ||
| quiche::FlagRegistry::getInstance(); | ||
| } | ||
|
|
||
|
|
@@ -53,6 +68,10 @@ createQuicNetworkConnection(Http::PersistentQuicInfo& info, Event::Dispatcher& d | |
| // This flag fix a QUICHE issue which may crash Envoy during connection close. | ||
| SetQuicReloadableFlag(quic_single_ack_in_packet2, true); | ||
| PersistentQuicInfoImpl* info_impl = reinterpret_cast<PersistentQuicInfoImpl*>(&info); | ||
| auto config = info_impl->cryptoConfig(); | ||
| if (config == nullptr) { | ||
| return nullptr; // no secrets available yet. | ||
| } | ||
|
|
||
| auto connection = std::make_unique<EnvoyQuicClientConnection>( | ||
| quic::QuicUtils::CreateRandomConnectionId(), server_addr, info_impl->conn_helper_, | ||
|
|
@@ -66,8 +85,8 @@ createQuicNetworkConnection(Http::PersistentQuicInfo& info, Event::Dispatcher& d | |
| // send_buffer_limit instead of using 0. | ||
| auto ret = std::make_unique<EnvoyQuicClientSession>( | ||
| info_impl->quic_config_, info_impl->supported_versions_, std::move(connection), | ||
| info_impl->server_id_, info_impl->crypto_config_.get(), &static_info.push_promise_index_, | ||
| dispatcher, /*send_buffer_limit=*/0); | ||
| info_impl->server_id_, std::move(config), &static_info.push_promise_index_, dispatcher, | ||
| /*send_buffer_limit=*/0); | ||
| return ret; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,9 +97,7 @@ class QuicClientTransportSocketFactory : public QuicTransportSocketFactoryBase { | |
| Ssl::ClientContextConfigPtr config, | ||
| Server::Configuration::TransportSocketFactoryContext& factory_context); | ||
|
|
||
| void initialize() override { | ||
| // TODO(14829) fallback_factory_ needs to call onSecretUpdated() upon SDS update. | ||
| } | ||
| void initialize() override {} | ||
|
|
||
| // As documented above for QuicTransportSocketFactoryBase, the actual HTTP/3 | ||
| // code does not create transport sockets. | ||
|
|
@@ -119,10 +117,8 @@ class QuicClientTransportSocketFactory : public QuicTransportSocketFactoryBase { | |
| } | ||
|
|
||
| protected: | ||
| void onSecretUpdated() override { | ||
| // fallback_factory_ will update the stats. | ||
| // TODO(14829) Client transport socket factory may also need to update quic crypto. | ||
| } | ||
| // fallback factory will update the context. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: capitalize Fallback or change back to |
||
| void onSecretUpdated() override {} | ||
|
|
||
| private: | ||
| // The QUIC client transport socket can create TLS sockets for fallback to TCP. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this cast guaranteed to succeed? Should it be a static_cast, and maybe an ASSERT that the dynamic_cast succeeds?