Adds MSI v2 (mTLS PoP) support: mtls_proof_of_possession and with_attestation_support APIs#882
Open
Adds MSI v2 (mTLS PoP) support: mtls_proof_of_possession and with_attestation_support APIs#882
mtls_proof_of_possession and with_attestation_support APIs#882Conversation
Co-authored-by: gladjohn <90415114+gladjohn@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Consolidate changes from PR #877 into single commit
[POC] Add MSI v2 (mTLS PoP) support: Feb 24, 2026
mtls_proof_of_possession and with_attestation_support APIs
…ensitive information Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
mtls_proof_of_possession and with_attestation_support APIsmtls_proof_of_possession and with_attestation_support APIs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #883
Description
Adds opt-in MSI v2 (mTLS Proof-of-Possession) support to
ManagedIdentityClient, enabling certificate-boundmtls_poptokens via Windows KeyGuard + attestation. MSI v2 activates only when both new per-call flags areTrue; all other paths are unchanged.API surface
screenshot (two calls to IDP, MAA called only once)
mtls_proof_of_possession=Truealone → falls through to MSI v1 (no-op)with_attestation_support=Truewithout PoP → raisesManagedIdentityErrorimmediatelyMsiV2Error— no silent fallback to v1New modules
msal/msi_v2.py— End-to-end Windows flow: NCrypt KeyGuard RSA key → PKCS#10 CSR (RSA-PSS/SHA-256, cuId OID attribute) → IMDS/getplatformmetadata+/issuecredential→ Crypt32 cert binding → WinHTTP/SChannel mTLS token request. Pure ctypes; no pythonnet.msal/msi_v2_attestation.py— P/Invoke bindings toAttestationClientLib.dllfor KeyGuard key attestation.Changes to existing modules
msal/managed_identity.py—MsiV2Error(ManagedIdentityError)added;acquire_token_for_client()gains two new keyword-onlyboolparams with full docstrings.msal/__init__.py— ExportsMsiV2Error.Samples & tests
sample/msi_v2_sample.py— Full E2E sample (strictmtls_popmode, optional endpoint call, env-var config).run_msi_v2_once.py+msi-v2-sample.spec— Minimal one-shot sample and PyInstaller build spec.tests/test_msi_v2.py— Unit tests covering thumbprint helpers,verify_cnf_binding, and gating behavior (all mocked; no IMDS/KeyGuard dependency).Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.