Skip to content

Clarify that the certificate validation cache is safely scoped per scheme - #68621

Merged
JanKrivanek merged 2 commits into
dotnet:mainfrom
JanKrivanek:msrc/clarify-certificate-cache-key-scoping
Aug 24, 2026
Merged

JanKrivanek merged 2 commits into
dotnet:mainfrom
JanKrivanek:msrc/clarify-certificate-cache-key-scoping

Conversation

@JanKrivanek

@JanKrivanek JanKrivanek commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Context

CertificateValidationCache is registered once as an app-wide singleton via AddCertificateCache(), which can look surprising at a glance since multiple certificate authentication schemes may share the same instance. This PR adds inline comments at the cache-key computation and at the singleton registration spelling out the intended behavior: ComputeKey already namespaces every entry by authentication scheme name before the certificate thumbprint, so sharing one cache instance across schemes is by design.

Change

Comment-only change in CertificateValidationCache.ComputeKey and CertificateAuthenticationExtensions.AddCertificateCache; no behavior change.

@JanKrivanek
JanKrivanek marked this pull request as ready for review August 18, 2026 16:03
Copilot AI lite review requested due to automatic review settings August 18, 2026 16:03

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.

Pull request overview

This PR clarifies (via inline comments) that CertificateValidationCache is safe to use as a singleton across multiple certificate authentication schemes because cache keys are scoped by scheme name.

Changes:

  • Add an explanatory comment in CertificateValidationCache.ComputeKey about scheme-name namespacing of cache entries.
  • Add an explanatory comment at AddCertificateCache where the cache is registered as a singleton.
Show a summary per file
File Description
src/Security/Authentication/Certificate/src/CertificateValidationCache.cs Adds a comment explaining how the cache key is namespaced by scheme name.
src/Security/Authentication/Certificate/src/CertificateAuthenticationExtensions.cs Adds a comment explaining why the singleton registration is safe across schemes.

Review details

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@JanKrivanek
JanKrivanek enabled auto-merge August 19, 2026 11:14
@JanKrivanek
JanKrivanek disabled auto-merge August 19, 2026 11:15
@JanKrivanek
JanKrivanek enabled auto-merge (squash) August 19, 2026 11:15
@JanKrivanek
JanKrivanek merged commit ce5b657 into dotnet:main Aug 24, 2026
25 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 25, 2026
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