-
Notifications
You must be signed in to change notification settings - Fork 379
Document mTLS PoP usage in MSAL (all pop features are on internal preview) #5584
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: main
Are you sure you want to change the base?
Changes from 2 commits
1e4087f
f291488
2294449
6d48ff3
dfaeff1
d7a50a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,173 @@ | ||||||
| --- | ||||||
| title: Use managed identities with mTLS proof-of-possession (preview) | ||||||
| description: Learn how to use managed identity with mTLS proof-of-possession tokens in MSAL.NET. | ||||||
| ms.service: entra-id | ||||||
| ms.subservice: develop | ||||||
| ms.topic: conceptual | ||||||
| ms.date: 11/17/2025 | ||||||
| --- | ||||||
|
|
||||||
| # Use managed identities with mTLS proof-of-possession (internal microsoft only - preview) | ||||||
|
|
||||||
| > [!IMPORTANT] | ||||||
| > mTLS proof-of-possession (mTLS PoP) for managed identities is currently in internal preview. | ||||||
| > | ||||||
| > To use `WithMtlsProofOfPossession`, you must add the package | ||||||
| > [`Microsoft.Identity.Client.MtlsPop`](https://www.nuget.org/packages/Microsoft.Identity.Client.MtlsPop) (for example, version `4.79.1-preview`). | ||||||
| > | ||||||
| > The resource (API) must be configured to accept mTLS PoP tokens and validate the certificate bound to the token. | ||||||
|
|
||||||
| mTLS PoP builds directly on top of the existing managed identity experience: | ||||||
|
|
||||||
| - You still use `ManagedIdentityApplicationBuilder`. | ||||||
| - You still call `AcquireTokenForManagedIdentity`. | ||||||
|
|
||||||
| The only changes are: | ||||||
|
|
||||||
| - Build Managed Identity app [using MSAL](https://learn.microsoft.com/en-us/entra/msal/dotnet/advanced/managed-identity). | ||||||
gladjohn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| - Add the MtlsPoP package. | ||||||
gladjohn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| - Add `.WithMtlsProofOfPossession()` when acquiring the token. | ||||||
| - Use the returned binding certificate when calling the API over mTLS. | ||||||
gladjohn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| Below we show the current (Bearer) code first, then the new (mTLS PoP) version, using Microsoft Graph as the example API. | ||||||
|
|
||||||
| ## 1. Add the MtlsPoP package | ||||||
gladjohn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| Install the preview package alongside `Microsoft.Identity.Client`: | ||||||
|
|
||||||
| ```bash | ||||||
| dotnet add package Microsoft.Identity.Client.MtlsPop --version 4.79.1-preview | ||||||
| ``` | ||||||
|
|
||||||
| This package: | ||||||
|
|
||||||
| - exposes the `WithMtlsProofOfPossession()` extension, and | ||||||
| - brings in a native dependency used to attest managed identity keys (for example KeyGuard keys) via Microsoft Azure Attestation (MAA). | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## 2. System-assigned managed identity – from Bearer to mTLS PoP (Graph) | ||||||
|
|
||||||
| ### Current experience – Bearer (Graph) | ||||||
|
|
||||||
| ```csharp | ||||||
| // System-assigned managed identity | ||||||
| IManagedIdentityApplication mi = | ||||||
| ManagedIdentityApplicationBuilder | ||||||
| .Create(ManagedIdentityId.SystemAssigned) | ||||||
| .Build(); | ||||||
|
|
||||||
| // Microsoft Graph as the target API | ||||||
| const string graphScope = "https://graph.microsoft.com/"; | ||||||
|
|
||||||
| AuthenticationResult result = await mi | ||||||
| .AcquireTokenForManagedIdentity(graphScope) | ||||||
| .ExecuteAsync() | ||||||
| .ConfigureAwait(false); | ||||||
|
|
||||||
| // result.AccessToken is a Bearer token (result.TokenType == "Bearer") | ||||||
| ``` | ||||||
|
|
||||||
| ### New experience – mTLS PoP (Graph) | ||||||
|
|
||||||
| ```csharp | ||||||
| // System-assigned managed identity | ||||||
| IManagedIdentityApplication mi = | ||||||
| ManagedIdentityApplicationBuilder | ||||||
| .Create(ManagedIdentityId.SystemAssigned) | ||||||
| .Build(); | ||||||
|
|
||||||
| // Microsoft Graph as the target API | ||||||
| const string graphScope = "https://graph.microsoft.com/"; | ||||||
|
|
||||||
| AuthenticationResult result = await mi | ||||||
| .AcquireTokenForManagedIdentity(graphScope) | ||||||
| .WithMtlsProofOfPossession() // <-- new API | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we started off, wouldn't this be redundant? |
||||||
| .ExecuteAsync() | ||||||
| .ConfigureAwait(false); | ||||||
|
|
||||||
| // result.TokenType == "mtls_pop" | ||||||
| // result.BindingCertificate is the client cert to use for mTLS | ||||||
gladjohn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| // result.BindingCertificate is the client cert to use for mTLS | |
| // result.BindingCertificate is the client cert to use for mTLS in step 4 |
gladjohn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
gladjohn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
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.
Why are these lines commented?
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.
just a comment in the code.
Uh oh!
There was an error while loading. Please reload this page.