-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add support for automatically adding the dev cert to the Windows certificate store when trusted in WSL #64966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Co-authored-by: danegsta <[email protected]>
…ecial characters Co-authored-by: danegsta <[email protected]>
…S script Co-authored-by: danegsta <[email protected]>
Fix command injection vulnerability in WSL certificate trust
… already exists and ensure that only a single error message is shown if there's an exception
| } | ||
|
|
||
| // Check to see if we're running in WSL; if so, use powershell.exe to add the certificate to the Windows trust store as well | ||
| if (IsRunningOnWslWithInterop()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we care if the other linux checks run? Should this check if sawTrustFailure is already true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it makes sense to skip just because we saw a failure as it still makes sense to run in a partial success state. There's already a check on line 338 that will exit early if there wasn't any success trusting the certificate, so if we made it to this point the certificate was at least trusted in some capacity. We still want all the other Linux specific logic to run on WSL since the goal is to trust it in both WSL and Windows in that case.
|
/backport to release/10.0 |
|
Started backporting to |
Add support for automatically adding the dev cert to the Windows certificate store when trusted in WSL
When trusting the dev cert in WSL, also trust it in the Windows cert store.
Description
Updates Unix certificate trust behavior to check if running in WSL in interop mode based on well known file paths and environment variables. If so, attempt to use Windows powershell to add the dev cert to the Windows certificate store (under
currentuser/root) as well with the friendly name "ASP.NET Core HTTPS development certificate (WSL)". This will allow Windows applications (particularly browsers) to trust local development traffic from .NET applications running in WSL.Adding the certificate to only
currentuser/rootwill allow the WSL certificate to be trusted, but Kestrel running on Windows won't attempt to use the certificate as it only looks for the dev cert incurrentuser/my, so if the user wants to run dotnet apps on Windows they'd still need to rundotnet dev-certs https --truston the Windows side to enable serving with the dev cert.Fixes #45208