Repository navigation
upstream tls: make the ca certs be shared across clusters - #47268
Conversation
Signed-off-by: wbpcode <[email protected]>
There was a problem hiding this comment.
🟢 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/CaCertListto 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.
|
/retest |
|
@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. |
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.