Skip to content

Commit 399a5ed

Browse files
tmdsamcasey
andauthored
UnixCertificateManager: implement IsTrusted. (#55335)
* UnixCertificateManager: implement IsTrusted. Consider the certificate trusted when .NET trusts it. * Add explanatory comment --------- Co-authored-by: Andrew Casey <[email protected]>
1 parent 7e6c237 commit 399a5ed

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Shared/CertificateGeneration/UnixCertificateManager.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ internal UnixCertificateManager(string subject, int version)
1818
{
1919
}
2020

21-
public override bool IsTrusted(X509Certificate2 certificate) => false;
21+
public override bool IsTrusted(X509Certificate2 certificate)
22+
{
23+
using X509Chain chain = new X509Chain();
24+
// This is just a heuristic for whether or not we should prompt the user to re-run with `--trust`
25+
// so we don't need to check revocation (which doesn't really make sense for dev certs anyway)
26+
chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
27+
return chain.Build(certificate);
28+
}
2229

2330
protected override X509Certificate2 SaveCertificateCore(X509Certificate2 certificate, StoreName storeName, StoreLocation storeLocation)
2431
{

0 commit comments

Comments
 (0)