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
UnixCertificateManager: implement IsTrusted. #55335
base: main
Are you sure you want to change the base?
Conversation
Consider the certificate trusted when .NET trusts it.
This is to omit the following warning when a development cert has been installed through https://github.com/tmds/linux-dev-certs.
When |
What validation does this perform? Just that the certificates in the chain are available and unexpired? |
Wait, is this check used exclusively to decide whether or not to print that warning? |
As implemented, this check tells us if
That, and there is another call in aspnetcore/src/Tools/dotnet-dev-certs/src/Program.cs Lines 298 to 315 in 08e84a2
I don't have a strong opinion on whether this one should be updated (to no longer special case Linux) or not. |
public override bool IsTrusted(X509Certificate2 certificate) | ||
{ | ||
using X509Chain chain = new X509Chain(); | ||
chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; |
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.
Why disable revocation checking? Perf?
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.
X509Chain
uses Online
as the default and SocketsHttpHandler
uses NoCheck
as the default.
If we don't set this to NoCheck
then verification fails because the local certificates have no online revocation list to check against.
I think this is a good idea today because if you went out of your way to manually trust the developer certificate or used something like I'm a little concerned that if in the future we try to resolve #7246 for dotnet-to-dotnet communications only by doing something like populating
I'd accept a PR that changes this, but I'd still want to special case Linux when the cert is missing so we can keep the link to https://aka.ms/dev-certs-trust. @Rick-Anderson What do you think about updating the docs at https://learn.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?view=aspnetcore-8.0&tabs=visual-studio%2Clinux-ubuntu#ssl-linux to mention https://github.com/tmds/linux-dev-certs? We'd probably want to call out that it's not officially supported by Microsoft, but it seems way more convenient than following the current instructions to trust the dev cert manually. |
+100 to this, until such time that we resolve #7246 |
{ | ||
using X509Chain chain = new X509Chain(); | ||
chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; | ||
return chain.Build(certificate); |
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.
Is there any reason not to use the logic on all platforms? It looks like on Windows we check for the cert in new X509Store(StoreName.Root, StoreLocation.CurrentUser)
specifically and on macOS we use security verify-cert -p basic -p ssl
on the exported dev cert. I'm not sure what advantages either of those things have over this. @javiercn
I'm on it dotnet/AspNetCore.Docs#32564 |
Consider the certificate trusted when .NET trusts it.
@davidfowl ptal.