-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Closed
Copy link
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Net.Http
Milestone
Description
Today with HttpClientHandler.ServerCertificateCustomValidationCallback you can do this to accept self-signed certificates:
var httpHandler = new HttpClientHandler();
// Return `true` to allow certificates that are untrusted/invalid
httpHandler.ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;This is good, but the predefined delegate is limited to HttpClientHandler. There are options specific to SocketsHttpHandler so devs sometimes must use it instead. When they use SocketsHttpHandler there isn't an equivalent for quickly accepting self-signed certificates. They must specify a delegate that returns true:
var httpHandler = new SocketsHttpHandler();
httpHandler.SslOptions.RemoteCertificateValidationCallback =
(object sender, X509Certificate? certificate, X509Chain? chain, SslPolicyErrors sslPolicyErrors) => true;It would be nice if there was a helper delegate for SocketsHttpHandler like DangerousAcceptAnyServerCertificateValidator:
var httpHandler = new SocketsHttpHandler();
httpHandler.SslOptions.RemoteCertificateValidationCallback =
SocketsHttpHandler.DangerousAcceptAnyServerCertificateValidator;The property could either go on SocketsHttpHandler, or SslClientAuthenticationOptions (which is where RemoteCertificateValidationCallback is defined)
geoffkizer and pablofrommars
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Net.Http