Load macOS Key Vault certs as Exportable only so private key survives…#5259
Merged
Merged
Conversation
… export On macOS, loading the Key Vault PKCS#12 with PersistKeySet imports the private key into the login Keychain, which cannot export the private key back out. That produced public-only PFX exports (~half the expected size) with no private key, breaking both the file-backed cert store and the base64 certs written to stdout. Select storage flags by OS: use Exportable only on macOS (no PersistKeySet) so the key stays in memory and can be exported to the file-backed store; keep Exportable | PersistKeySet on Windows/Linux. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts how Key Vault–sourced PKCS#12 certificates are imported by CertHelper so macOS retains an exportable private key, enabling correct PFX re-export into the macOS file-backed cert store and base64 output.
Changes:
- Selects
X509KeyStorageFlagsbased on OS: macOS usesExportableonly; other OSes useExportable | PersistKeySet. - Applies the selected flags consistently to both the NET9
X509CertificateLoader.LoadPkcs12path and the pre-NET9X509Certificate2constructor path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
LoopedBard3
approved these changes
Jul 10, 2026
matouskozak
approved these changes
Jul 10, 2026
matouskozak
left a comment
Member
There was a problem hiding this comment.
Thank you for the quick fix
This was referenced Jul 10, 2026
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.
… export
On macOS, loading the Key Vault PKCS#12 with PersistKeySet imports the private key into the login Keychain, which cannot export the private key back out. That produced public-only PFX exports (~half the expected size) with no private key, breaking both the file-backed cert store and the base64 certs written to stdout.
Select storage flags by OS: use Exportable only on macOS (no PersistKeySet) so the key stays in memory and can be exported to the file-backed store; keep Exportable | PersistKeySet on Windows/Linux.