-
Notifications
You must be signed in to change notification settings - Fork 1.4k
add upstream info #2434
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
add upstream info #2434
Changes from all 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 |
|---|---|---|
|
|
@@ -178,6 +178,11 @@ bool IsMutualTLS(const Network::Connection* connection) { | |
| connection->ssl()->peerCertificatePresented(); | ||
| } | ||
|
|
||
| bool IsUpstreamMutualTLS(const StreamInfo::StreamInfo& stream_info) { | ||
| const auto ssl = stream_info.upstreamSslConnection(); | ||
| return ssl != nullptr && ssl->peerCertificatePresented(); | ||
|
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. I'm a little confused on the usage of
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. Ouch, I think this might be an issue. We should be checking whether a local certificate was presented, not peer.
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. that's what I thought. I don't see an Envoy API for that. @lizan may be you know better?
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. We can extend envoy to report whether a local certificate is presented. That might not mean that the server validated it. Not sure how to get that info.
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. we didn't have this in Envoy API because this has been simply reflecting what in the TLS context config, though we're adding more dynamic nature to the config for incremental adoption etc, so it makes sense to add, thanks for posting envoyproxy/envoy#8464. |
||
| } | ||
|
|
||
| bool GetRequestedServerName(const Network::Connection* connection, | ||
| std::string* name) { | ||
| if (connection && !connection->requestedServerName().empty()) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,9 +52,12 @@ bool GetPrincipal(const Network::Connection* connection, bool peer, | |
| bool GetTrustDomain(const Network::Connection* connection, bool peer, | ||
| std::string* trust_domain); | ||
|
|
||
| // Returns true if connection is mutual TLS enabled. | ||
| // Returns true if downstream connection is mutual TLS enabled. | ||
|
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. rename this to IsDownstreamMutualTLS? |
||
| bool IsMutualTLS(const Network::Connection* connection); | ||
|
|
||
| // Returns true if upstream connection is mutual TLS enabled. | ||
| bool IsUpstreamMutualTLS(const StreamInfo::StreamInfo& stream_info); | ||
|
|
||
| // Get requested server name, SNI in case of TLS | ||
| bool GetRequestedServerName(const Network::Connection* connection, | ||
| std::string* name); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -280,6 +280,14 @@ void AttributesBuilder::ExtractReportAttributes( | |
| } | ||
|
|
||
| builder.FlattenMapOfStringToStruct(report_data->GetDynamicFilterState()); | ||
|
|
||
| builder.AddBool(utils::AttributeName::kUpstreamMtls, | ||
| report_data->IsUpstreamMutualTLS()); | ||
|
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. just a nit. instead of having a bool for mutual TLs, why not have an enum of sorts? upstream: plaintext, tls, mutualTLS ? We are coming across a lot of setups where the sidecar has to terminate one way TLS on VMs.
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. Enums are generally painful to deal with in proto. mTLS is special since that's the end state, so it's needed to track the progress on getting to that state. We can populate other TLS properties later (e.g. version, cipher suite ID, etc). |
||
| const std::string &failure_reason = report_data->GetUpstreamFailureReason(); | ||
| if (!failure_reason.empty()) { | ||
| builder.AddString(utils::AttributeName::kUpstreamFailureReason, | ||
| failure_reason); | ||
| } | ||
| } | ||
|
|
||
| } // namespace http | ||
|
|
||
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.
how does work with this attribute
kConnectionMtlsUh oh!
There was an error while loading. Please reload this page.
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.
connection.mtls means downstream connection mTLS status.
upstream.mtls means upstream connection mTLS status.
Depending on whether the proxy acts like an outbound or an inbound sidecar, you use one or the other.
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.
i see, may be this attribute
kConnectionMtlsneeds to explicitly say that it's related to downstream. It's can be confusing specially after adding this new attribute.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.
+1
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.
We can't change the meaning of existing attributes. There are UIs that have expectations. We can change the metric, however, in istio config.