Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

gladjohn
Copy link
Contributor

Fixes -

Changes proposed in this request
• Purpose: Persist and reuse mTLS binding certificate to enable cache lookups under mtls_pop scheme.
• Non-goals: Certificate rotation strategy, multi-cert pool, persistence across processes.
• Follow-up items: (a) Coalescing concurrent first-mint, (b) Attaching binding cert to result (if not in this PR), (c) Tests enabling previously skipped assertions.
• Risk assessment: Low; internal-only; no behavior change for bearer path.

Testing
unit tests

Performance impact
none

Documentation

  • All relevant documentation is updated.

@gladjohn gladjohn requested a review from a team as a code owner October 15, 2025 17:21
if (AuthenticationRequestParameters.IsMtlsPopRequested &&
!(AuthenticationRequestParameters.AuthenticationScheme is MtlsPopAuthenticationOperation))
{
var priorCert = _managedIdentityClient.RuntimeMtlsBindingCertificate;
Copy link
Contributor

Choose a reason for hiding this comment

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

What if _managedIdentityClient.RuntimeMtlsBindingCertificate is null? Should this be inside the if statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Guarded with priorCert != null


// Prime the scheme before any cache lookup if we already have a binding cert from a prior mint
if (AuthenticationRequestParameters.IsMtlsPopRequested &&
!(AuthenticationRequestParameters.AuthenticationScheme is MtlsPopAuthenticationOperation))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please explain to me why this 2nd check is needed? If AuthenticationRequestParameters.IsMtlsPopRequested is true, then why do we care if the authentication scheme is not MtlsPopAuthenticationOperation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simplified, you are correct it is not needed


ManagedIdentityRequest request = await CreateRequestAsync(resource).ConfigureAwait(false);

if (parameters.IsMtlsPopRequested && request?.MtlsCertificate != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you leave a comment here explaining when the MtlsCertificate would already be in the request? Would it be there when there was already a mTLS PoP request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a brief comment in AbstractManagedIdentity.AuthenticateAsync explaining that IMDSv2 mints the binding cert during CSR/attestation and exposes it on the request

Comment on lines 168 to 170
RuntimeMtlsBindingCertificate = cert;
//dispose prior stored cert on replacement
old?.Dispose();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I would swap these lines

Copy link
Contributor

Choose a reason for hiding this comment

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

How does Dispose() work? Is that part of .NET? Does it communicate to the cert store on the OS?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added an XML remark clarifying that Dispose() releases the object’s resources and does not remove a cert from the OS store (that’s X509Store.Remove)

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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.