Skip to content

Add configurable certificate StoreLocation for certificate authentication#49

Merged
MichalFrends1 merged 23 commits intomainfrom
copilot/add-storelocation-selection-certificates
Mar 3, 2026
Merged

Add configurable certificate StoreLocation for certificate authentication#49
MichalFrends1 merged 23 commits intomainfrom
copilot/add-storelocation-selection-certificates

Conversation

Copy link
Contributor

Copilot AI commented Nov 14, 2025

Summary: Add StoreLocation selection for certificate authentication

Problem

Users were unable to select which certificate store location to use when authenticating with certificates. The code was hardcoded to use StoreLocation.CurrentUser, making it impossible to use certificates from StoreLocation.LocalMachine without writing custom request code.

Solution

Added a new configurable option CertificateStoreLocation that allows users to select between CurrentUser and LocalMachine when using certificate authentication from the certificate store.

Changes Made:

  • Created CertificateStoreLocation enum with CurrentUser and LocalMachine options in all 5 HTTP modules
  • Added CertificateStoreLocation property to Options classes with default value of CurrentUser (backward compatible)
  • Updated GetCertificatesFromStore methods to accept and use the selected store location
  • Updated error messages to indicate which store location was searched
  • Successfully built all 5 modules with no errors
  • Passed security review (CodeQL found 0 alerts)
  • Bumped minor versions for all modules (non-breaking change)
  • Added changelog entries for all modules
  • Fixed DownloadFile tests to use MockHttp instead of external Wikipedia URL
  • Added unit tests for CertificateStoreLocation feature and error cases
  • Fixed failing test by using real HttpClientFactory to trigger certificate lookup exception
  • Fixed whitespace formatting issues reported by superlinter
  • Added additional tests for 80%+ code coverage

Version Updates:

  • ✅ Frends.HTTP.Request: 1.5.0 → 1.6.0
  • ✅ Frends.HTTP.SendBytes: 1.4.0 → 1.5.0
  • ✅ Frends.HTTP.RequestBytes: 1.3.0 → 1.4.0
  • ✅ Frends.HTTP.SendAndReceiveBytes: 1.3.0 → 1.4.0
  • ✅ Frends.HTTP.DownloadFile: 1.3.0 → 1.4.0

Test Coverage Improvements:

Added new tests for:

  • Empty URL validation (throws ArgumentNullException)

  • CertificateStoreLocation.CurrentUser explicit test

  • CertificateStoreLocation.LocalMachine with non-existent thumbprint (throws exception)

  • Overwrite=false with existing file (throws exception)

  • Authorization header deduplication

  • WindowsAuthentication username validation

  • Certificate from file with/without keyPhrase

  • Certificate from string with keyPhrase

  • Null headers handling

  • Client caching behavior

  • Basic auth with empty headers

  • OAuth auth with empty headers

  • Fixes Would like to be able to select StoreLocation when using Certificate #39

Original prompt

This section details on the original issue you should resolve

<issue_title>Would like to be able to select StoreLocation when using Certificate</issue_title>
<issue_description>Currently when making a request using certificate it only fetches certificates from StoreLocation.CurrentUser in Extensions.cs row 111.

We have a project where we need to be able to choose which StoreLocation the cert lives in. So the only solution here currently is to write the requests manually.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai
Copy link

coderabbitai bot commented Nov 14, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 2 commits November 14, 2025 13:40
Co-authored-by: jefim <1387820+jefim@users.noreply.github.com>
Co-authored-by: jefim <1387820+jefim@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ability to select StoreLocation when using certificate Add configurable certificate StoreLocation for certificate authentication Nov 14, 2025
Copilot AI requested a review from jefim November 14, 2025 13:48
@jefim
Copy link
Contributor

jefim commented Nov 18, 2025

@copilot Ok, now need to bump the versions (I think this is a non-breaking change, so second version number bump) and add changelog entries to correct files.

…feature

Co-authored-by: jefim <1387820+jefim@users.noreply.github.com>

This comment was marked as outdated.

@jefim jefim marked this pull request as ready for review November 18, 2025 04:20
@jefim

This comment was marked as outdated.

This comment was marked as outdated.

@jefim

This comment was marked as outdated.

…Http

Co-authored-by: jefim <1387820+jefim@users.noreply.github.com>

This comment was marked as outdated.

@jefim

This comment was marked as outdated.

Co-authored-by: jefim <1387820+jefim@users.noreply.github.com>

This comment was marked as outdated.

Co-authored-by: jefim <1387820+jefim@users.noreply.github.com>

This comment was marked as outdated.

Copy link
Contributor

@MatteoDelOmbra MatteoDelOmbra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it looks good, just add those default values and cover new functionality with test in all tasks (test should prove at least sunny scenario for new store location option)

@MatteoDelOmbra
Copy link
Contributor

In general it looks good, just add those default values and cover new functionality with test in all tasks (test should prove at least sunny scenario for new store location option)

We are currently testing on linux machine. Do we want to change that for those tests (cert store we support works on Windows only)?

  • It will be more todo, as we need to create cert for tests, retrieve somehow it's thumbprint and use it in test input - I guess it is doable, but idk if it's necessary (either way for some reason we've excluded whole Extensions class from test coverage)

@MatteoDelOmbra MatteoDelOmbra requested review from MichalFrends1 and removed request for jefim March 2, 2026 11:08
Copy link
Contributor

@MichalFrends1 MichalFrends1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fix one date in the changelog ;)

@MichalFrends1 MichalFrends1 merged commit 4176ce4 into main Mar 3, 2026
6 checks passed
@MichalFrends1 MichalFrends1 deleted the copilot/add-storelocation-selection-certificates branch March 3, 2026 13:40
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.

Would like to be able to select StoreLocation when using Certificate

4 participants