Skip to content

tls: fix ssl.no_certificate doc and add ssl.no_certificate_for_upstream for upstream/cluster TLS handshakes#43669

Open
botengyao wants to merge 11 commits intoenvoyproxy:mainfrom
botengyao:fix-tls-no-cert-stats
Open

tls: fix ssl.no_certificate doc and add ssl.no_certificate_for_upstream for upstream/cluster TLS handshakes#43669
botengyao wants to merge 11 commits intoenvoyproxy:mainfrom
botengyao:fix-tls-no-cert-stats

Conversation

@botengyao
Copy link
Member

@botengyao botengyao commented Feb 27, 2026

https://www.envoyproxy.io/docs/envoy/latest/configuration/upstream/cluster_manager/cluster_stats.html#tls-statistics

no_certificate: total successful TLS connections with no client certificate

  1. The ssl.no_certificate stat was never incremented on cluster (client-side) TLS contexts and update the doc to use peer.
  2. And added a new stats ssl.client_certificate_presented, which is useful for cluster metrics to detect mtls

Risk Level: low
Testing: unit

Signed-off-by: Boteng Yao <boteng@google.com>
Signed-off-by: Boteng Yao <boteng@google.com>
@botengyao
Copy link
Member Author

/retest

@kyessenov
Copy link
Contributor

I am not sure it's a good idea to change the stats like this. Stats are actually an API, so changes should be done carefully. I suggest adding a new stats on whether client responded with to server requesting a client cert, only available on the upstream ssl. and change the doc to indicate "no_certificate" is a "peer" cert.

Signed-off-by: Boteng Yao <boteng@google.com>
Signed-off-by: Boteng Yao <boteng@google.com>
Signed-off-by: Boteng Yao <boteng@google.com>
Signed-off-by: Boteng Yao <boteng@google.com>
Signed-off-by: Boteng Yao <boteng@google.com>
@botengyao botengyao changed the title tls: fix ssl.no_certificate stat for upstream/cluster TLS handshakes tls: fix ssl.no_certificate doc and add ssl.no_certificate_for_upstream for upstream/cluster TLS handshakes Mar 1, 2026
Signed-off-by: Boteng Yao <boteng@google.com>
@botengyao
Copy link
Member Author

upstream ssl. and change the doc to indicate "no_certificate" is a "peer" cert

yes, agreed this is better, thanks for the feedback.

@botengyao
Copy link
Member Author

@kyessenov @ggreenway, this is ready, PTAL, thanks!

:header: Name, Type, Description
:widths: 1, 1, 2

no_certificate_for_upstream, Counter, Total successful upstream TLS connections with no client certificate provided
Copy link
Contributor

@kyessenov kyessenov Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll defer to @ggreenway here, but I think it'd make more sense to do it the other, e.g. have client_certificate stat that's incremented when client presents a cert. mTLS is less common than TLS, so it'd make sense for the default to be zeroes.

Copy link
Member Author

@botengyao botengyao Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, good suggestion, and I also don't have a strong opinion. changes done.

Signed-off-by: Boteng Yao <boteng@google.com>

const std::string server_ctx_yaml = R"EOF(
common_tls_context:
tls_certificates:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually not an mTLS setup, or am I missing something? There should be request-client-cert option enabled.

Copy link
Member Author

@botengyao botengyao Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this is intentional, but I think the real way to say it is mTLS from client side is to add a callback when server asks certificate from client, so the stats is only fired when there is a cert from client side and the server is asking it.

I updated a new version of this support, but more code, PTAL for which one do you prefer.

Signed-off-by: Boteng Yao <boteng@google.com>
@botengyao botengyao force-pushed the fix-tls-no-cert-stats branch from 4225e1a to 739f353 Compare March 3, 2026 04:07
}

// Delegate to the cert selector if one exists.
if (context_impl->tls_certificate_selector_ != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you have to do this - a default cert selector would be cleaner, and then you can track the state in the handshaker directly. This would be the same as the server side, which always uses a cert selector.

But it's worth double checking whether bssl already records this information somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants