forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 63
Refactor SdsApi to support dynamic certificate validation context. #11
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9cb2e20
Refactor SdsApi to support dynamic certificate validation context.
JimmyCYJ aa06142
test: Stop fake_upstream methods from accidentally succeeding (#4232)
mkbehr ae6a252
router: fix matching when all domains have wildcards (#4326)
talnordan e34dcd6
Fix crash in tcp_proxy (#4323)
ggreenway f936fc6
ssl: serialize accesses to SSL socket factory contexts (#4345)
akonradi 763f2a7
thrift: refactor Thrift router to allow protocol upgrade (#4286)
zuercher ee710d0
Add terminal attribute to request hash. (#4292)
stevenzzzz cd35a2c
Revise per comments.
JimmyCYJ 61bdf6c
pass sds config name as const std::string&.
JimmyCYJ cf3cbf3
Add explicit instantiation.
JimmyCYJ a905c0a
Update tests.
JimmyCYJ 7707c3b
fix time_since_epoch different in different os default return precisi…
zyfjeff 1537e68
test: another echo_integration_test fix (#4350)
zuercher c4211b3
not to writeQueued if cq is drained (#4356)
qiwzhang d9414bd
Merge remote-tracking branch 'envoyupstream/master' into refactor_sds…
JimmyCYJ a12b042
Add test and refactor SdsApi.
JimmyCYJ 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 |
|---|---|---|
|
|
@@ -64,10 +64,10 @@ SecretManagerImpl::createInlineCertificateValidationContextProvider( | |
| certificate_validation_context); | ||
| } | ||
|
|
||
| void SecretManagerImpl::removeDynamicSecretProvider(const std::string& map_key) { | ||
| ENVOY_LOG(debug, "Unregister secret provider. hash key: {}", map_key); | ||
| void SecretManagerImpl::removeDynamicTlsCertificateProvider(const std::string& map_key) { | ||
| ENVOY_LOG(debug, "Unregister tls certificate provider. hash key: {}", map_key); | ||
|
|
||
| auto num_deleted = dynamic_secret_providers_.erase(map_key); | ||
| auto num_deleted = dynamic_tls_certificate_providers_.erase(map_key); | ||
| ASSERT(num_deleted == 1, ""); | ||
| } | ||
|
|
||
|
|
@@ -76,22 +76,59 @@ TlsCertificateConfigProviderSharedPtr SecretManagerImpl::findOrCreateTlsCertific | |
| Server::Configuration::TransportSocketFactoryContext& secret_provider_context) { | ||
| const std::string map_key = sds_config_source.SerializeAsString() + config_name; | ||
|
|
||
| TlsCertificateConfigProviderSharedPtr secret_provider = dynamic_secret_providers_[map_key].lock(); | ||
| TlsCertificateConfigProviderSharedPtr secret_provider = | ||
| dynamic_tls_certificate_providers_[map_key].lock(); | ||
| if (!secret_provider) { | ||
| ASSERT(secret_provider_context.initManager() != nullptr); | ||
|
|
||
| // SdsApi is owned by ListenerImpl and ClusterInfo which are destroyed before | ||
| // SecretManagerImpl. It is safe to invoke this callback at the destructor of SdsApi. | ||
| std::function<void()> unregister_secret_provider = [map_key, this]() { | ||
| removeDynamicSecretProvider(map_key); | ||
| removeDynamicTlsCertificateProvider(map_key); | ||
| }; | ||
|
|
||
| secret_provider = std::make_shared<SdsApi>( | ||
| secret_provider = std::make_shared<TlsCertificateSdsApi>( | ||
| secret_provider_context.localInfo(), secret_provider_context.dispatcher(), | ||
| secret_provider_context.random(), secret_provider_context.stats(), | ||
| secret_provider_context.clusterManager(), *secret_provider_context.initManager(), | ||
| sds_config_source, config_name, unregister_secret_provider); | ||
| dynamic_secret_providers_[map_key] = secret_provider; | ||
| dynamic_tls_certificate_providers_[map_key] = secret_provider; | ||
| } | ||
|
|
||
| return secret_provider; | ||
| } | ||
|
|
||
| void SecretManagerImpl::removeDynamicCertificateValidationContextProvider( | ||
| const std::string& map_key) { | ||
| ENVOY_LOG(debug, "Unregister certificate validation context provider. hash key: {}", map_key); | ||
|
|
||
| auto num_deleted = dynamic_certificate_validation_context_providers_.erase(map_key); | ||
| ASSERT(num_deleted == 1, ""); | ||
| } | ||
|
|
||
| CertificateValidationContextConfigProviderSharedPtr | ||
|
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 like the fact that many of code are duplicated. But I don't have good solution either. |
||
| SecretManagerImpl::findOrCreateCertificateValidationContextProvider( | ||
| const envoy::api::v2::core::ConfigSource& sds_config_source, const std::string& config_name, | ||
| Server::Configuration::TransportSocketFactoryContext& secret_provider_context) { | ||
| const std::string map_key = sds_config_source.SerializeAsString() + config_name; | ||
|
|
||
| CertificateValidationContextConfigProviderSharedPtr secret_provider = | ||
| dynamic_certificate_validation_context_providers_[map_key].lock(); | ||
| if (!secret_provider) { | ||
| ASSERT(secret_provider_context.initManager() != nullptr); | ||
|
|
||
| // SdsApi is owned by ListenerImpl and ClusterInfo which are destroyed before | ||
| // SecretManagerImpl. It is safe to invoke this callback at the destructor of SdsApi. | ||
| std::function<void()> unregister_secret_provider = [map_key, this]() { | ||
| removeDynamicCertificateValidationContextProvider(map_key); | ||
| }; | ||
|
|
||
| secret_provider = std::make_shared<CertificateValidationContextSdsApi>( | ||
| secret_provider_context.localInfo(), secret_provider_context.dispatcher(), | ||
| secret_provider_context.random(), secret_provider_context.stats(), | ||
| secret_provider_context.clusterManager(), *secret_provider_context.initManager(), | ||
| sds_config_source, config_name, unregister_secret_provider); | ||
| dynamic_certificate_validation_context_providers_[map_key] = secret_provider; | ||
| } | ||
|
|
||
| return secret_provider; | ||
|
|
||
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.
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.
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.
const std::string&