-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Specify type for matching Subject Alternative Name. #18628
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 9 commits
3c47ebb
a554236
9d3a7e9
3d6272e
f3c87a6
ff9cd5f
7287a34
3aae6db
ab5cd11
135391e
2a65d30
086ece5
42c2f75
e028388
cebac65
e8226dd
b083021
af0c18b
bdc7c4e
67d05d1
b4bb871
0d880c0
7970de4
35265c6
d5e2ec4
9901676
4af6264
f6eefd6
caec188
b1b0261
831ad94
947da60
711b024
c0113a9
7bcd271
d0e365b
bb5dc55
14b6c0f
5ee23dd
b4d8863
cd8d388
e8c36bb
6adfb56
d94cc3e
b1bfe77
d4dd073
3bc3cb6
e034baf
d8aaafb
de0525a
cc2b181
00f151c
36226ea
133a6a8
c5b05ab
05fb9b0
d97b59f
6ceb50d
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 |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import "envoy/type/matcher/v3/string.proto"; | |
| import "google/protobuf/any.proto"; | ||
| import "google/protobuf/wrappers.proto"; | ||
|
|
||
| import "envoy/annotations/deprecation.proto"; | ||
| import "udpa/annotations/migrate.proto"; | ||
| import "udpa/annotations/sensitive.proto"; | ||
| import "udpa/annotations/status.proto"; | ||
|
|
@@ -253,7 +254,29 @@ message CertificateProviderPluginInstance { | |
| string certificate_name = 2; | ||
| } | ||
|
|
||
| // [#next-free-field: 14] | ||
| // String matcher for subject alternative names, to match both type and value of the SAN. | ||
| message StringSanMatcher { | ||
| enum SanType { | ||
| EMAIL_ID = 0; | ||
| DNS_ID = 1; | ||
| URI_ID = 2; | ||
|
mathetake marked this conversation as resolved.
Outdated
|
||
| IP_ADD = 3; | ||
|
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.
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. Done |
||
| } | ||
|
|
||
| SanType san_type = 1 [(validate.rules).enum.defined_only = true]; | ||
|
|
||
| type.matcher.v3.StringMatcher matcher = 2; | ||
|
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. I think this can be annotated with
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. Modified existing rule to exclude default value. Added comments.
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. IIUC this allows a config with a defined |
||
| } | ||
|
|
||
| message SubjectAltNameMatcher { | ||
|
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. Please add comments describing the message and field. |
||
| oneof matcher { | ||
| StringSanMatcher string_matcher = 1; | ||
|
|
||
| config.core.v3.TypedExtensionConfig typed_config = 2; | ||
|
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. Do we need this extension point? If someone needs to extend, can they just do it as
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. To me, it makes more sense to have the extension point, as the string matcher does not work for all san types, and it is specifically only the san matcher that needs special handling in those cases, and not the entire validator config. Does that sound like a reasonable argument to you?
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. Is anyone actually going to write an extension for this extension point? Or is it just hypothetical need?
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. The extension is needed to support OtherName as defined on page 38 here https://www.rfc-editor.org/rfc/pdfrfc/rfc5280.txt.pdf, which can be any user-defined type. As of now Envoy does not support this, but we will need to add it in the future if we would want to support SRV-ID or UPN (User Principle Name) which are othernames.
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. Unless someone plans to add that support in the immediate future, I'd rather not add it until it's used. If it is added and never used, it creates extra maintenance burden for no gain.
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. Sounds good to me. |
||
| } | ||
| } | ||
|
|
||
| // [#next-free-field: 15] | ||
| message CertificateValidationContext { | ||
| option (udpa.annotations.versioning).previous_message_type = | ||
| "envoy.api.v2.auth.CertificateValidationContext"; | ||
|
|
@@ -388,6 +411,8 @@ message CertificateValidationContext { | |
|
|
||
| // An optional list of Subject Alternative name matchers. If specified, Envoy will verify that the | ||
| // Subject Alternative Name of the presented certificate matches one of the specified matchers. | ||
| // The matching uses "any" semantics, that is to say, the SAN is verified if at least one matcher is | ||
| // matched. | ||
| // | ||
| // When a certificate has wildcard DNS SAN entries, to match a specific client, it should be | ||
| // configured with exact match type in the :ref:`string matcher <envoy_v3_api_msg_type.matcher.v3.StringMatcher>`. | ||
|
|
@@ -396,15 +421,23 @@ message CertificateValidationContext { | |
| // | ||
| // .. code-block:: yaml | ||
| // | ||
| // match_subject_alt_names: | ||
| // exact: "api.example.com" | ||
| // match_subject_alt_names_with_type: | ||
| // string_matcher: | ||
| // san_type: DNS_ID | ||
|
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.
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. Done |
||
| // matcher: | ||
| // exact: "api.example.com" | ||
| // | ||
| // .. attention:: | ||
| // | ||
| // Subject Alternative Names are easily spoofable and verifying only them is insecure, | ||
| // therefore this option must be used together with :ref:`trusted_ca | ||
| // <envoy_v3_api_field_extensions.transport_sockets.tls.v3.CertificateValidationContext.trusted_ca>`. | ||
|
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. Can you improve the comment by mentioning that this has an Any semantics (the SAN is verified if at least one of the matchers is matched) |
||
| repeated type.matcher.v3.StringMatcher match_subject_alt_names = 9; | ||
| repeated SubjectAltNameMatcher match_subject_alt_names_with_type = 14; | ||
|
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. An alternative API that I think is simpler is to have a message of StringMatcher and an enum for the type of match. Thoughts?
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. That was exactly my first pass implementation. However, I could not find a simple way to extend it to support OtherName (eg. Microsoft UPN), the value for which could be a string or a complex message.
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. Jus thinking out loud here: if the typical use-case is using on of the types noted below, then it might make sense to have a
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. I think this would need lot of control planes to know about the type of SAN - which forces all the existing APIs to add the type (like DestintationRule API) in Istio which treats SANs as string. IMO this leads to lot of churn. Can we also accept cc: @howardjohn
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. Hi Rama, Howard,
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. Consider renaming to But neither of these names are really correct, because this type allows either a typed-matcher, or a typed_config which could be anything. But I'm failing to think of a good name for this. |
||
|
|
||
| // This field is deprecated in favor of ref:`match_subject_alt_names_with_type | ||
| // <envoy_v3_api_field_extensions.transport_sockets.tls.v3.CertificateValidationContext.match_subject_alt_names_with_type>` | ||
| repeated type.matcher.v3.StringMatcher match_subject_alt_names = 9 | ||
| [deprecated = true, (envoy.annotations.deprecated_at_minor_version) = "3.0"]; | ||
|
|
||
| // [#not-implemented-hide:] Must present signed certificate time-stamp. | ||
| google.protobuf.BoolValue require_signed_certificate_timestamp = 6; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,14 +6,39 @@ | |
|
|
||
| #include "envoy/api/api.h" | ||
| #include "envoy/common/pure.h" | ||
| #include "envoy/config/core/v3/extension.pb.h" | ||
| #include "envoy/config/typed_config.h" | ||
| #include "envoy/extensions/transport_sockets/tls/v3/cert.pb.h" | ||
| #include "envoy/extensions/transport_sockets/tls/v3/common.pb.h" | ||
| #include "envoy/type/matcher/v3/string.pb.h" | ||
|
|
||
| #include "absl/types/optional.h" | ||
| #include "openssl/x509v3.h" | ||
|
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. Putting this into an interface header may lead to complications with building various configurations of envoy. Please validate that envoy without any TLS extensions included still builds. Or move this interface to be internal to the tls transport_socket, and then we don't have to worry about it.
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. Moved the interface. |
||
|
|
||
| namespace Envoy { | ||
| namespace Ssl { | ||
|
|
||
| /** Interface to verify if there is a match in a list of subject alternative | ||
| * names. | ||
| */ | ||
| class SanMatcher { | ||
| public: | ||
| virtual bool match(GENERAL_NAMES const*) const PURE; | ||
| virtual ~SanMatcher() = default; | ||
| }; | ||
|
|
||
| using SanMatcherPtr = std::unique_ptr<SanMatcher>; | ||
|
|
||
| class SanMatcherFactory : public Config::TypedFactory { | ||
|
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. Given that there isn't an extension point for this, why register a factory type?
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. Yikes. I did have an extension point but did not remove this when I removed the extension point. Fixed. |
||
| public: | ||
| ~SanMatcherFactory() override = default; | ||
|
|
||
| virtual SanMatcherPtr | ||
| createSanMatcher(const envoy::config::core::v3::TypedExtensionConfig* config) PURE; | ||
|
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. It might be better to pass the config by reference, unless it can be null
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. sgtm |
||
|
|
||
| std::string category() const override { return "envoy.san_matchers"; } | ||
| }; | ||
|
|
||
| class CertificateValidationContextConfig { | ||
| public: | ||
| virtual ~CertificateValidationContextConfig() = default; | ||
|
|
@@ -43,7 +68,7 @@ class CertificateValidationContextConfig { | |
| /** | ||
| * @return The subject alt name matchers to be verified, if enabled. | ||
| */ | ||
| virtual const std::vector<envoy::type::matcher::v3::StringMatcher>& | ||
| virtual const std::vector<envoy::extensions::transport_sockets::tls::v3::SubjectAltNameMatcher>& | ||
| subjectAltNameMatchers() const PURE; | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,10 +1,13 @@ | ||||||
| #include "source/common/ssl/certificate_validation_context_config_impl.h" | ||||||
|
|
||||||
| #include "envoy/common/exception.h" | ||||||
| #include "envoy/config/core/v3/extension.pb.h" | ||||||
| #include "envoy/extensions//transport_sockets/tls/v3/common.pb.h" | ||||||
|
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. I think this is what causing your format error.
Suggested change
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. Thanks! Great catch! |
||||||
| #include "envoy/extensions/transport_sockets/tls/v3/cert.pb.h" | ||||||
|
|
||||||
| #include "source/common/common/empty_string.h" | ||||||
| #include "source/common/common/fmt.h" | ||||||
| #include "source/common/common/logger.h" | ||||||
| #include "source/common/config/datasource.h" | ||||||
|
|
||||||
| namespace Envoy { | ||||||
|
|
@@ -22,8 +25,7 @@ CertificateValidationContextConfigImpl::CertificateValidationContextConfigImpl( | |||||
| certificate_revocation_list_path_( | ||||||
| Config::DataSource::getPath(config.crl()) | ||||||
| .value_or(certificate_revocation_list_.empty() ? EMPTY_STRING : INLINE_STRING)), | ||||||
| subject_alt_name_matchers_(config.match_subject_alt_names().begin(), | ||||||
| config.match_subject_alt_names().end()), | ||||||
| subject_alt_name_matchers_(getSubjectAltNameMatchers(config)), | ||||||
| verify_certificate_hash_list_(config.verify_certificate_hash().begin(), | ||||||
| config.verify_certificate_hash().end()), | ||||||
| verify_certificate_spki_list_(config.verify_certificate_spki().begin(), | ||||||
|
|
@@ -36,6 +38,7 @@ CertificateValidationContextConfigImpl::CertificateValidationContextConfigImpl( | |||||
| config.custom_validator_config()) | ||||||
| : absl::nullopt), | ||||||
| api_(api) { | ||||||
|
|
||||||
| if (ca_cert_.empty() && custom_validator_config_ == absl::nullopt) { | ||||||
| if (!certificate_revocation_list_.empty()) { | ||||||
| throw EnvoyException(fmt::format("Failed to load CRL from {} without trusted CA", | ||||||
|
|
@@ -51,5 +54,32 @@ CertificateValidationContextConfigImpl::CertificateValidationContextConfigImpl( | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| std::vector<envoy::extensions::transport_sockets::tls::v3::SubjectAltNameMatcher> | ||||||
| CertificateValidationContextConfigImpl::getSubjectAltNameMatchers( | ||||||
| const envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext& config) { | ||||||
| if (!config.match_subject_alt_names_with_type().empty() && | ||||||
| !config.match_subject_alt_names().empty()) { | ||||||
| throw EnvoyException("SAN-based verification using both match_subject_alt_names_with_type and " | ||||||
| "the deprecated match_subject_alt_names is not allowed"); | ||||||
| } | ||||||
| std::vector<envoy::extensions::transport_sockets::tls::v3::SubjectAltNameMatcher> | ||||||
| subject_alt_name_matchers(config.match_subject_alt_names_with_type().begin(), | ||||||
| config.match_subject_alt_names_with_type().end()); | ||||||
| // Handle deprecated string type san matchers without san type specified, by | ||||||
| // creating backwards compatible san matcher configs. | ||||||
| for (auto& matcher : config.match_subject_alt_names()) { | ||||||
| subject_alt_name_matchers.emplace_back(); | ||||||
|
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. You may be able to iterate over the values [
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'd rather be explicit here. If new enum types are added in the future, those should NOT be iterated over in this loop, as this is for backwards compatibility ONLY.
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. So in this case I suggest to refactor the code to iterate over the specific set of enum values, and add them (decrease code duplication).
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. Fixed |
||||||
| subject_alt_name_matchers.back().set_allocated_typed_config( | ||||||
| new ::envoy::config::core::v3::TypedExtensionConfig()); | ||||||
| subject_alt_name_matchers.back().mutable_typed_config()->set_allocated_typed_config( | ||||||
| new ProtobufWkt::Any()); | ||||||
| subject_alt_name_matchers.back().mutable_typed_config()->mutable_typed_config()->PackFrom( | ||||||
| matcher); | ||||||
| subject_alt_name_matchers.back().mutable_typed_config()->mutable_name()->assign( | ||||||
| "envoy.san_matchers.backward_compatible_san_matcher"); | ||||||
|
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. Instead of allocating new objects you should be able to create the TypedExtensionConfig object on the stack, and pack it into the
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. Aah, didn't realise that |
||||||
| } | ||||||
| return subject_alt_name_matchers; | ||||||
| } | ||||||
|
|
||||||
| } // namespace Ssl | ||||||
| } // namespace Envoy | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,13 +18,15 @@ | |
| #include "source/common/common/hex.h" | ||
| #include "source/common/common/matchers.h" | ||
| #include "source/common/common/utility.h" | ||
| #include "source/common/config/utility.h" | ||
| #include "source/common/network/address_impl.h" | ||
| #include "source/common/protobuf/utility.h" | ||
| #include "source/common/runtime/runtime_features.h" | ||
| #include "source/common/stats/symbol_table_impl.h" | ||
| #include "source/common/stats/utility.h" | ||
| #include "source/extensions/transport_sockets/tls/cert_validator/cert_validator.h" | ||
| #include "source/extensions/transport_sockets/tls/cert_validator/factory.h" | ||
| #include "source/extensions/transport_sockets/tls/cert_validator/san_matcher_config.h" | ||
| #include "source/extensions/transport_sockets/tls/cert_validator/utility.h" | ||
| #include "source/extensions/transport_sockets/tls/stats.h" | ||
| #include "source/extensions/transport_sockets/tls/utility.h" | ||
|
|
@@ -144,9 +146,19 @@ int DefaultCertValidator::initializeSslContexts(std::vector<SSL_CTX*> contexts, | |
| const Envoy::Ssl::CertificateValidationContextConfig* cert_validation_config = config_; | ||
| if (cert_validation_config != nullptr) { | ||
| if (!cert_validation_config->subjectAltNameMatchers().empty()) { | ||
| for (const envoy::type::matcher::v3::StringMatcher& matcher : | ||
| for (const envoy::extensions::transport_sockets::tls::v3::SubjectAltNameMatcher& matcher : | ||
| cert_validation_config->subjectAltNameMatchers()) { | ||
| subject_alt_name_matchers_.push_back(Matchers::StringMatcherImpl(matcher)); | ||
| if (matcher.has_string_matcher()) { | ||
| subject_alt_name_matchers_.emplace_back(createStringSanMatcher(matcher.string_matcher())); | ||
| } else { | ||
| auto const factory = | ||
| Envoy::Config::Utility::getAndCheckFactory<Envoy::Ssl::SanMatcherFactory>( | ||
| matcher.typed_config(), true); | ||
| if (factory != nullptr) { | ||
| subject_alt_name_matchers_.emplace_back( | ||
| factory->createSanMatcher(&matcher.typed_config())); | ||
| } | ||
| } | ||
| } | ||
| verify_mode = verify_mode_validation_context; | ||
| } | ||
|
|
@@ -218,8 +230,8 @@ int DefaultCertValidator::doVerifyCertChain( | |
|
|
||
| // If `trusted_ca` exists, it is already verified in the code above. Thus, we just need to make | ||
| // sure the verification for other validation context configurations doesn't fail (i.e. either | ||
| // `NotValidated` or `Validated`). If `trusted_ca` doesn't exist, we will need to make sure other | ||
| // configurations are verified and the verification succeed. | ||
| // `NotValidated` or `Validated`). If `trusted_ca` doesn't exist, we will need to make sure | ||
| // other configurations are verified and the verification succeed. | ||
| int validation_status = verify_trusted_ca_ | ||
| ? validated != Envoy::Ssl::ClientValidationStatus::Failed | ||
| : validated == Envoy::Ssl::ClientValidationStatus::Validated; | ||
|
|
@@ -229,8 +241,7 @@ int DefaultCertValidator::doVerifyCertChain( | |
|
|
||
| Envoy::Ssl::ClientValidationStatus DefaultCertValidator::verifyCertificate( | ||
| X509* cert, const std::vector<std::string>& verify_san_list, | ||
| const std::vector<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>& | ||
| subject_alt_name_matchers) { | ||
| const std::vector<Envoy::Ssl::SanMatcherPtr>& subject_alt_name_matchers) { | ||
| Envoy::Ssl::ClientValidationStatus validated = Envoy::Ssl::ClientValidationStatus::NotValidated; | ||
|
|
||
| if (!verify_san_list.empty()) { | ||
|
|
@@ -308,26 +319,28 @@ bool DefaultCertValidator::dnsNameMatch(const absl::string_view dns_name, | |
| return false; | ||
| } | ||
|
|
||
| bool DefaultCertValidator::verifySubjectAltName( | ||
|
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. Should this function by part of SanMatcher? It's only called from there.
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. Fixed. |
||
| const GENERAL_NAME* general_name, | ||
| Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher> const& matcher) { | ||
| // For DNS SAN, if the StringMatcher type is exact, we have to follow DNS matching semantics. | ||
| const std::string san = Utility::generalNameAsString(general_name); | ||
| return general_name->type == GEN_DNS && | ||
| matcher.matcher().match_pattern_case() == | ||
| envoy::type::matcher::v3::StringMatcher::MatchPatternCase::kExact | ||
| ? dnsNameMatch(matcher.matcher().exact(), absl::string_view(san)) | ||
| : matcher.match(san); | ||
| } | ||
|
|
||
| bool DefaultCertValidator::matchSubjectAltName( | ||
| X509* cert, | ||
| const std::vector<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>>& | ||
| subject_alt_name_matchers) { | ||
| X509* cert, const std::vector<Envoy::Ssl::SanMatcherPtr>& subject_alt_name_matchers) { | ||
| bssl::UniquePtr<GENERAL_NAMES> san_names( | ||
| static_cast<GENERAL_NAMES*>(X509_get_ext_d2i(cert, NID_subject_alt_name, nullptr, nullptr))); | ||
| if (san_names == nullptr) { | ||
| return false; | ||
| } | ||
| for (const GENERAL_NAME* general_name : san_names.get()) { | ||
| const std::string san = Utility::generalNameAsString(general_name); | ||
| for (auto& config_san_matcher : subject_alt_name_matchers) { | ||
| // For DNS SAN, if the StringMatcher type is exact, we have to follow DNS matching semantics. | ||
| if (general_name->type == GEN_DNS && | ||
| config_san_matcher.matcher().match_pattern_case() == | ||
| envoy::type::matcher::v3::StringMatcher::MatchPatternCase::kExact | ||
| ? dnsNameMatch(config_san_matcher.matcher().exact(), absl::string_view(san)) | ||
| : config_san_matcher.match(san)) { | ||
| return true; | ||
| } | ||
| for (auto& config_san_matcher : subject_alt_name_matchers) { | ||
|
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.
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. Fixed. |
||
| if (config_san_matcher->match(san_names.get())) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
|
|
||
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.
Please add a comment here with the link to the relevant RFC section.
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.
Added comment.