Add private key password support to GDS Client certificate flows - #745
Merged
Conversation
Wire up a masked password input in ApplicationCertificateControl so users can supply a private key password. The password now feeds new key-pair requests, CSR signing, and PFX read/write, and LoadPrivateKeyAsync loads store-backed keys with it instead of being a no-op. Also fixes loading the GDS-returned PFX with the request password. Fixes #743 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Proposed changes
The GDS Client had a
m_certificatePasswordfield that was threaded through the request, signing, and PFX code paths but was only ever initialized tonull. There was no UI element to enter a private key password, so every flow resolved to an empty/null password and password-protected keys could not be used.This change adds a masked password input to
ApplicationCertificateControland wires it into all relevant flows:Private Key Passwordtext box (UseSystemPasswordChar) in the registration buttons panel, synced intom_certificatePasswordon change and reset on initialization.LoadPrivateKeyAsyncwas a no-op stub that ignored its password argument. It now opens the certificate store and loads the private key using the supplied password (falling back to the public-only certificate when the store does not support key loading or no match is found).string.Emptyinstead of the request password, which would fail to decrypt a password-protected PFX.Verified with a local build of
GlobalDiscoveryClient.csproj(0 warnings, 0 errors).Related Issues
Types of changes
What types of changes does your code introduce?
Put an
xin the boxes that apply. You can also fill these out after creating the PR.Checklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Further comments
This is a WinForms sample control, so the change is UI-driven and not covered by automated tests. The password is read directly from the text box into the existing field, keeping the surrounding request/signing/PFX code paths unchanged aside from now receiving a real password.
LoadPrivateKeyAsyncintentionally degrades gracefully to the public certificate rather than throwing, to preserve existing behavior when a store does not support private-key export.