Skip to content

upstream tls: make the ca certs be shared across clusters - #47268

Merged
wbpcode merged 1 commit into
envoyproxy:mainfrom
wbpcode:dev-cache-ca-cert
Sep 9, 2026
Merged

wbpcode merged 1 commit into
envoyproxy:mainfrom
wbpcode:dev-cache-ca-cert

Conversation

@wbpcode

@wbpcode wbpcode commented Sep 7, 2026

Copy link
Copy Markdown
Member

Commit Message: upstream tls: make the ca certs be shared across clusters
Additional Description:

See envoyproxy/gateway#9489 for why this makes sense.

Actually there are more context that could be shared. But the CA is the most safe/simple one to share. So, it should be a good start to reduce unnecessary memory footprint.

Risk Level: low.
Testing: unit.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The caching/lifetime model mirrors the existing CRL cache pattern, and the added unit tests cover the key sharing and error-path behaviors.

Pull request overview

This PR introduces a process-wide trusted CA certificate cache so that identical CA PEM content referenced from many TLS contexts (common in upstream clusters) is parsed once and shared, reducing memory duplication of parsed X509 objects.

Changes:

  • Added CaCertCache / CaCertList to share parsed CA certs (and any CRLs embedded in the CA PEM) across TLS contexts via the Singleton manager.
  • Updated DefaultCertValidator::initializeSslContexts() to load trusted CAs through the shared cache rather than reparsing per context.
  • Added unit tests covering cache sharing, separation for distinct content, lifetime behavior, and integration via multiple validators.
File summaries
File Description
test/common/tls/cert_validator/default_validator_test.cc Adds unit tests validating CA cache behavior and that multiple validators share a single parsed trust bundle.
source/common/tls/cert_validator/default_validator.h Introduces CaCertCache/CaCertList types and wires the validator to hold a shared CA entry.
source/common/tls/cert_validator/default_validator.cc Implements the CA cache as a Singleton and updates CA loading to reuse cached parsed certs/CRLs.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@wbpcode

wbpcode commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

/retest

@wbpcode
wbpcode merged commit bcebd3b into envoyproxy:main Sep 9, 2026
28 checks passed
@ramaraochavali

Copy link
Copy Markdown
Contributor

@wbpcode curious, how much memory savings did you see with this?

@wbpcode
wbpcode deleted the dev-cache-ca-cert branch September 10, 2026 02:00
@wbpcode

wbpcode commented Sep 10, 2026 •

Copy link
Copy Markdown
Member Author

@wbpcode curious, how much memory savings did you see with this?

Hello, Rama. It's depends the size of CA and also the cluster numbers. Because the EG will create a cluster for every route before and our customer have a relatively big CA, so it's become a problem. In most cases, I guess previous design is fine. But the cache is harmless because in most case, all clusters will share same CA and the cache at least could reduce unnecessary cert parsing.

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.

4 participants