-
Notifications
You must be signed in to change notification settings - Fork 375
[MSI V2] - Adds Authentication Operation to MSI v2 mTLS flows #5533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rginsburg/msiv2_feature_branch
Are you sure you want to change the base?
[MSI V2] - Adds Authentication Operation to MSI v2 mTLS flows #5533
Conversation
if (AuthenticationRequestParameters.IsMtlsPopRequested && | ||
!(AuthenticationRequestParameters.AuthenticationScheme is MtlsPopAuthenticationOperation)) | ||
{ | ||
var priorCert = _managedIdentityClient.RuntimeMtlsBindingCertificate; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
RuntimeMtlsBindingCertificate = cert; | ||
//dispose prior stored cert on replacement | ||
old?.Dispose(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
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