Skip to content

Refactors loading cert in EntraMockResponsePlugin. Closes #1610 - #1612

Merged
waldekmastykarz merged 3 commits into
dotnet:mainfrom
waldekmastykarz:fix-1610
Apr 14, 2026
Merged

waldekmastykarz merged 3 commits into
dotnet:mainfrom
waldekmastykarz:fix-1610

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Collaborator

Refactors loading cert in EntraMockResponsePlugin. Closes #1610

@waldekmastykarz
waldekmastykarz requested a review from a team as a code owner April 11, 2026 13:37
@waldekmastykarz waldekmastykarz added the pr-bugfix Fixes a bug label Apr 11, 2026
Copilot AI review requested due to automatic review settings April 11, 2026 13:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors EntraMockResponsePlugin to avoid resolving the root X509Certificate2 during plugin construction (which can fail early in startup), and instead resolves it when it’s actually needed while processing mock responses—addressing the startup crash reported in #1610.

Changes:

  • Replace constructor injection of X509Certificate2 with injection of IServiceProvider.
  • Resolve X509Certificate2 on-demand when generating the dynamic key id and certificate chain placeholders.

Comment thread DevProxy.Plugins/Mocking/EntraMockResponsePlugin.cs
Comment thread DevProxy.Plugins/Mocking/EntraMockResponsePlugin.cs Outdated

@garrytrinder garrytrinder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tested locally. Proxy starts cleanly with EntraMockResponsePlugin enabled (no more X509Certificate2 DI crash), and mock token responses are returned correctly. LGTM.

@waldekmastykarz
waldekmastykarz merged commit 53524f2 into dotnet:main Apr 14, 2026
4 checks passed
@waldekmastykarz
waldekmastykarz deleted the fix-1610 branch April 14, 2026 10:40
waldekmastykarz added a commit that referenced this pull request Apr 14, 2026
* Refactors loading cert in EntraMockResponsePlugin. Closes #1610

* Removes dead null check after GetRequiredService
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: EntraMockResponsePlugin crashes on startup: Unable to resolve service for type X509Certificate2

3 participants