Fix GDS Client cert path placeholder expansion when saving certificates - #747
Merged
Conversation
When saving a new certificate, GetAbsoluteFilePath only resolves paths to files that already exist, so for a not-yet-created file it failed and the code fell back to the raw path with an unexpanded %CommonApplicationData% placeholder. Route the public and private key save paths through a new GetSaveFilePath helper that falls back to Utils.ReplaceSpecialFolderNames so placeholders are consistently expanded and certs are written to the intended location. Fixes #740 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
When saving certificates via the GDS Client, environment/special-folder placeholders such as
%CommonApplicationData%in the public/private key path fields were sometimes not expanded, causing certs to be written to an unexpected literal path (or the save to fail).The root cause is that
Utils.GetAbsoluteFilePath(...)only resolves paths to files that already exist. When saving a new certificate the target file does not exist yet, so the call fails and the code fell back to the raw path (?? m_application.CertificatePublicKeyPath), which still contained the unexpanded placeholder.This change routes the public and private key save paths in
ApplicationCertificateControlthrough a newGetSaveFilePathhelper. The helper first triesGetAbsoluteFilePath(to keep existing behavior for files that exist and current-directory lookups), and on failure falls back toUtils.ReplaceSpecialFolderNames, which expands placeholders regardless of whether the file exists yet. As a result, placeholders are consistently expanded and certs are written to the intended location. The read/load paths were intentionally left unchanged since those target existing files.Related Issues
Types of changes
What types of changes does your code introduce?
Checklist
Further comments
The GDS Client sample is a WinForms app with no automated UI test harness, so this was verified by building the
GlobalDiscoveryClientproject (net10.0-windows) which compiled with 0 errors. The helper is deliberately tolerant of both the throwing and null-returning behaviors ofGetAbsoluteFilePathacross library versions.