Open
Description
By default, both SslStream and HttpClient will not perform any revocation checking. We should consider changing to a secure defaults.
Note that there is some inconsistency in different ways to configure Chain verification.
X509ChainPolicy specifies Online
by default
However, SslAuthenticationOptions do not
And, by their extension, neither will SocketsHttpHandler. This leads to inconsistent behaviors, consider following
{
System.Console.WriteLine("default HttpClient");
using HttpClient client = new HttpClient();
var response = await client.GetAsync("https://www.microsoft.com");
}
{
System.Console.WriteLine("default SocketsHttpHandler");
using HttpClient client = new HttpClient(new SocketsHttpHandler { });
var response = await client.GetAsync("https://www.microsoft.com");
}
{
System.Console.WriteLine("default SocketsHttpHandler with default ctor chain policy");
using HttpClient client = new HttpClient(new SocketsHttpHandler
{
SslOptions = {
CertificateChainPolicy = new X509ChainPolicy()
}
});
var response = await client.GetAsync("https://www.microsoft.com");
}
When I add debug console log of the effective revocation check mode, I get
❯ dotnet run
default HttpClient
ChainPolicy.RevocationMode = NoCheck
default SocketsHttpHandler
ChainPolicy.RevocationMode = NoCheck
default SocketsHttpHandler with default ctor chain policy
ChainPolicy.RevocationMode = Online
Despite not explicitly configuring revocation check mode in either case.
Note that this is also in line with new analyzers for CA5399: Enable HttpClient certificate revocation list check analyzer.