Skip to content

Fix GDS Client cert path placeholder expansion when saving certificates - #747

Merged
romanett merged 1 commit into
masterfrom
romanett-gds-cert-path-expansion
Aug 13, 2026
Merged

Fix GDS Client cert path placeholder expansion when saving certificates#747
romanett merged 1 commit into
masterfrom
romanett-gds-cert-path-expansion

Conversation

@romanett

Copy link
Copy Markdown
Contributor

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 ApplicationCertificateControl through a new GetSaveFilePath helper. The helper first tries GetAbsoluteFilePath (to keep existing behavior for files that exist and current-directory lookups), and on failure falls back to Utils.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?

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

The GDS Client sample is a WinForms app with no automated UI test harness, so this was verified by building the GlobalDiscoveryClient project (net10.0-windows) which compiled with 0 errors. The helper is deliberately tolerant of both the throwing and null-returning behaviors of GetAbsoluteFilePath across library versions.

@romanett
romanett merged commit 6e41051 into master Aug 13, 2026
2 of 7 checks passed
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>
@romanett
romanett deleted the romanett-gds-cert-path-expansion branch August 14, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GDS Client: %CommonApplicationData% not replaced in public/private key path field when saving certs

1 participant