Skip to content

tls: allow multiple TLS certificates in the upstream when using a custom TLS certificate selector - #46479

Open
Berro321 wants to merge 12 commits into
envoyproxy:mainfrom
Berro321:multiple-tls-certs
Open

tls: allow multiple TLS certificates in the upstream when using a custom TLS certificate selector#46479
Berro321 wants to merge 12 commits into
envoyproxy:mainfrom
Berro321:multiple-tls-certs

Conversation

@Berro321

@Berro321 Berro321 commented Jul 31, 2026

Copy link
Copy Markdown

Commit Message: Allow multiple TLS certificates in the upstream tls context when using a custom TLS certificate selector. The single cert check is kept if one is not defined.

Additional Description: We are working on an internal TLS certificate selector for UpstreamTLSContext that can select between multiple client certificate. By default only one is allowed, so we need a way to allow multiple once our custom TLS certificate selector is enabled.
Risk Level: Medium
Testing: Added unit tests, tested manually to check it works with our custom cert selector.
Docs Changes: Added documentation in the API proto for tls_certificates to indicate multiple certs are allowed in a client context when a custom TLS certificate selector is used.
Release Notes: Added a release note under new features.
Platform Specific Features: N/A

a custom tls cert selector is used for the
upstream.

Signed-off-by: Berro321 <matchburn321@gmail.com>
@repokitteh-read-only

Copy link
Copy Markdown

Hi @Berro321, 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: #46479 was opened by Berro321.

see: more, trace.

@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #46479 was opened by Berro321.

see: more, trace.

@Berro321
Berro321 had a problem deploying to external-contributors July 31, 2026 05:45 — with GitHub Actions Error
Signed-off-by: Berro321 <matchburn321@gmail.com>
@Berro321
Berro321 had a problem deploying to external-contributors July 31, 2026 20:29 — with GitHub Actions Error
Signed-off-by: Berro321 <matchburn321@gmail.com>
@Berro321
Berro321 temporarily deployed to external-contributors July 31, 2026 20:57 — with GitHub Actions Inactive
@Berro321
Berro321 marked this pull request as ready for review July 31, 2026 21:18
@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @adisuissa
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #46479 was ready_for_review by Berro321.

see: more, trace.

@adisuissa adisuissa 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.

/lgtm api

@repokitteh-read-only repokitteh-read-only Bot removed the api label Aug 5, 2026
@adisuissa

Copy link
Copy Markdown
Contributor

Assigning @botengyao as codeowner
/assign @botengyao

@Berro321
Berro321 temporarily deployed to external-contributors August 5, 2026 22:45 — with GitHub Actions Inactive
@Berro321

Berro321 commented Aug 5, 2026

Copy link
Copy Markdown
Author

/retest

@Berro321
Berro321 had a problem deploying to external-contributors August 7, 2026 20:14 — with GitHub Actions Error
Signed-off-by: Berro321 <matchburn321@gmail.com>
@Berro321
Berro321 deployed to external-contributors August 7, 2026 20:52 — with GitHub Actions Active
@Berro321
Berro321 had a problem deploying to external-contributors August 11, 2026 19:30 — with GitHub Actions Error
@Berro321

Copy link
Copy Markdown
Author

/retest

@Berro321
Berro321 deployed to external-contributors August 12, 2026 17:33 — with GitHub Actions Active
@Berro321
Berro321 had a problem deploying to external-contributors August 13, 2026 20:55 — with GitHub Actions Error

@botengyao botengyao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks for adding this support, module some high level comments.

/wait

Comment thread source/common/tls/client_context_impl.h Outdated
ASSERT(tls_contexts_.size() == 1);
return tls_contexts_[0];
}
const Ssl::TlsContext& getTlsContext() const override { return tls_contexts_[0]; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do not think we should simply remove this assertion. Ssl::ClientContext still documents that client contexts have exactly one TLS context, while returning [0] now silently means “bootstrap/default context,” not necessarily the selected context. Since the selector already uses getTlsContexts(), please keep getTlsContext() restricted to single-context callers and update its interface documentation, or redesign the public accessor to represent multiple contexts explicitly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have left it restricted to single context callers

// invariant ever changes, getTlsContext() must be updated to handle multiple TLS contexts.
if (tls_contexts_.size() != 1) {
// If a custom TLS certificate selector is used, allow more than one TLS cert.
if (!config.tlsCertificateSelectorFactory() && tls_contexts_.size() != 1) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This needs to account for session resumption before allowing multiple client identities. newSsl() installs a cached session before the certificate callback, and the cache is keyed only by SNI. A session created after selecting cert A can therefore be resumed by a connection whose selector would choose cert B. On an accepted TLS 1.2 resumption, the server does not send a new CertificateRequest, so selectTlsContext() is never invoked and the resumed connection retains A’s authenticated session identity. Since max_session_keys defaults to 1, this is enabled by default. Please either require max_session_keys: 0 for this configuration or introduce selector-aware session-cache partitioning that is determined before ClientHello.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added comment for setting max_session_keys to 0

Signed-off-by: Berro321 <matchburn321@gmail.com>
@Berro321
Berro321 deployed to external-contributors August 18, 2026 20:08 — with GitHub Actions Active
@Berro321
Berro321 requested a review from botengyao August 18, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants