Skip to content

Conversation

@danegsta
Copy link
Member

@danegsta danegsta commented Jan 7, 2026

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/root will 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 in currentuser/my, so if the user wants to run dotnet apps on Windows they'd still need to run dotnet dev-certs https --trust on the Windows side to enable serving with the dev cert.

image

Fixes #45208

@danegsta danegsta linked an issue Jan 7, 2026 that may be closed by this pull request
@github-actions github-actions bot added the area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI label Jan 7, 2026
Copy link
Contributor

Copilot AI left a 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.

Copy link
Contributor

Copilot AI commented Jan 7, 2026

@danegsta I've opened a new pull request, #64969, to work on those changes. Once the pull request is ready, I'll request review from you.

@danegsta danegsta enabled auto-merge (squash) January 8, 2026 22:09
}

// 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())
Copy link
Member

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?

Copy link
Member Author

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.

@danegsta danegsta merged commit ab855c5 into main Jan 8, 2026
25 checks passed
@danegsta danegsta deleted the danegsta/wslCertTrust branch January 8, 2026 23:17
@dotnet-policy-service dotnet-policy-service bot added this to the 11.0-preview1 milestone Jan 8, 2026
@danegsta
Copy link
Member Author

danegsta commented Jan 8, 2026

/backport to release/10.0

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Started backporting to release/10.0 (link to workflow run)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support to dotnet dev-certs for managing HTTPS certs in WSL

4 participants