Skip to content

attributes: add connection.peer_certificate_valid attribute#45828

Open
thc1006 wants to merge 3 commits into
envoyproxy:mainfrom
thc1006:attributes/peer-certificate-valid
Open

attributes: add connection.peer_certificate_valid attribute#45828
thc1006 wants to merge 3 commits into
envoyproxy:mainfrom
thc1006:attributes/peer-certificate-valid

Conversation

@thc1006

@thc1006 thc1006 commented Jun 24, 2026

Copy link
Copy Markdown

Commit Message: Add the connection.peer_certificate_valid CEL attribute, a bool indicating whether the downstream peer certificate was presented and validated.

Additional Description:
In optional mTLS configurations using trust_chain_verification: ACCEPT_UNTRUSTED, Envoy may accept a downstream connection even when the presented client certificate is untrusted. The existing connection.mtls CEL attribute reports whether a peer certificate was presented, but it does not report whether that certificate was validated.

This adds connection.peer_certificate_valid, implemented alongside connection.mtls and backed by the existing Ssl::ConnectionInfo::peerCertificateValidated() API. The two attributes together distinguish the relevant downstream TLS states:

  • no certificate presented: connection.mtls=false, connection.peer_certificate_valid=false
  • certificate presented and validated: connection.mtls=true, connection.peer_certificate_valid=true
  • certificate presented but not validated, for example when accepted under ACCEPT_UNTRUSTED: connection.mtls=true, connection.peer_certificate_valid=false

No interface change is needed. The implementation reuses the existing peerCertificateValidated() getter and only exposes that state as a read-only CEL attribute.

Risk Level: Low. This is an additive, read-only CEL attribute and does not change the TLS handshake, certificate validation path, or existing connection.mtls behavior.

Testing:

  • Added coverage in test/extensions/filters/common/expr/context_test.cc.
  • The existing ConnectionAttributes test covers the validated certificate case.
  • Added ConnectionPeerCertificateNotValidated to cover the presented-but-not-validated case.
  • Locally ran the unit test, changelog validation, format checks, spelling check, clang-tidy build for the changed targets, and DCO verification.

Docs Changes:
Added connection.peer_certificate_valid to docs/root/intro/arch_overview/advanced/attributes.rst.

Release Notes:
Added changelogs/current/new_features/attributes__added-peer-certificate-valid-cel.rst.

Platform Specific Features: None

AI usage:
This change was written with the assistance of generative AI tooling. I have reviewed it, fully understand it, and take ownership of the code.

Fixes #45660

thc1006 added 2 commits June 24, 2026 15:00
Add the connection.peer_certificate_valid CEL attribute, a bool reflecting
whether the downstream peer certificate was presented and validated. It
exposes the existing Ssl::ConnectionInfo::peerCertificateValidated() and is
implemented the same way as connection.mtls.

In an optional mTLS setup (trust_chain_verification: ACCEPT_UNTRUSTED) the
handshake succeeds even when the client certificate is untrusted.
connection.mtls already reports whether a certificate was presented; this
reports whether it validated, so RBAC, CEL and route matching can use it
without resorting to a Lua filter.

Risk Level: Low
Testing: unit tests (test/extensions/filters/common/expr/context_test.cc)
Docs Changes: yes
Release Notes: yes
Fixes envoyproxy#45660

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Correct "ceritificate" to "certificate" in the connection.mtls row of the
CEL attributes table.

Risk Level: Low
Testing: n/a (documentation only)
Docs Changes: yes
Release Notes: no

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
@thc1006 thc1006 had a problem deploying to external-contributors June 24, 2026 13:21 — with GitHub Actions Error
@repokitteh-read-only

Copy link
Copy Markdown

Hi @thc1006, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #45828 was opened by thc1006.

see: more, trace.

… test

Add connection.peer_certificate_valid to the ext_proc RequestResponseAttributes
integration test, asserting it is false on a non-TLS downstream connection
(matching connection.mtls), and update the present-attribute count.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
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.

Expose TLS peer certificate validation status in CEL context etc.

1 participant