-
Notifications
You must be signed in to change notification settings - Fork 378
Revise certificate handling documentation for MSI v2 #5515
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
Open
gladjohn
wants to merge
7
commits into
main
Choose a base branch
from
gladjohn-patch-13
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+78
−0
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f919cab
Revise certificate handling documentation for MSI v2
gladjohn 0aba5e4
Update cert_handling.md
gladjohn cee0524
Include proactive renewal instructions for certificates
gladjohn 57b7ca3
Update cert_handling.md
gladjohn 31ff5b9
Merge branch 'main' into gladjohn-patch-13
gladjohn f47d9da
Merge branch 'main' into gladjohn-patch-13
gladjohn 5958527
Merge branch 'main' into gladjohn-patch-13
gladjohn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Certificate Handling on Windows for MSI v2 / PoP | ||
|
|
||
| ## Overview | ||
| In the MSI v2 flow, the client must present a certificate over mTLS. | ||
| The certificate itself is the **credential** for this flow. | ||
|
|
||
| Currently, the certificate is stored only in memory. | ||
| To reduce repeated calls to IMDS and enable reuse across requests, | ||
| the certificate should be **rooted (persisted)** in the Windows certificate store. | ||
|
|
||
| ## 1. Certificate Store Location | ||
| - Use the **Windows Certificate Store**. | ||
| - Scope: **CurrentUser\My** store (per-user, not global). | ||
| - This provides: | ||
| - Secure key isolation (KeyGuard). | ||
| - OS-enforced ACLs instead of manual file permissions. | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Certificate Lifecycle | ||
|
|
||
| 1. **Check Cert Store** | ||
| - Look in `CurrentUser\My` for an MSI certificate. | ||
| - Identify by subject and issuer. | ||
| - If found and not expired → load it. | ||
|
|
||
| 2. **No Valid Certificate** | ||
| - Generate a key pair (RSA) in KeyGuard (for POP). | ||
| - Get an attestation token for the key. | ||
| - Create CSR in memory. | ||
| - Call **IMDS issuecredential** endpoint. | ||
| - Receive certificate from IMDS. | ||
|
|
||
| 3. **Persist the Certificate** | ||
| - Store the new certificate (with private key) in `CurrentUser\My`. | ||
| - Mark the key as **non-exportable**. (uses KeyGuard keys - already non-exportable) | ||
|
|
||
| 4. **Use Certificate** | ||
| - Load cert from store as needed. | ||
| - Use it for mTLS handshake. | ||
|
|
||
| --- | ||
|
|
||
| ## 3. Expiration and Renewal | ||
| - Certificates are short-lived (7 days). | ||
| - Always check expiration before use. | ||
| - If expired or close to expiry: | ||
| - Remove stale cert from store. | ||
| - Acquire and persist a new cert from IMDS. | ||
|
|
||
| --- | ||
|
|
||
| ## 4. Error Handling | ||
| - If store entry is corrupt → remove it and fetch new cert. | ||
| - If IMDS call fails → bubble up error to caller. | ||
|
|
||
| --- | ||
|
|
||
| # Certificate Store Location in Linux | ||
| - Linux has no OS-backed cert store like Windows. | ||
| - Define a **per-user store** under the home directory: ~/.config/msal/certs/ | ||
gladjohn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - File naming convention: | ||
| - `msal_mtls.pfx` (PKCS#12) or | ||
| - `msal_mtls.pem` (PEM with key + cert). | ||
| - Permissions: | ||
| - Directory = `700` (only the user can read/write/execute). | ||
| - File = `600` (only the user can read/write). | ||
|
|
||
| --- | ||
|
|
||
| ## 5. Security Considerations | ||
| - Private keys must be generated in **CNG/KeyGuard** with `ExportPolicy = None`. | ||
| - Keys should **never** be exported or persisted outside the Windows certificate store. | ||
| - `CurrentUser\My` is scoped to the signed-in user. | ||
| - For service scenarios, use `LocalMachine\My` with proper ACLs. | ||
|
|
||
| --- | ||
|
|
||
| ## ✅ Summary | ||
| - Always **check Windows cert store first** (`CurrentUser\My`). | ||
| - If no valid cert, **request one from IMDS**. | ||
| - **Persist it** back into the store securely. | ||
| - **Refresh on expiration**. | ||
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.
Uh oh!
There was an error while loading. Please reload this page.