-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Add support for ServerCertificateCustomValidationCallback #1319
Add support for ServerCertificateCustomValidationCallback #1319
Comments
What you are suggesting is not possible (or at least easily doable) because the TLS negotiation it's handled by the native code and it's complex to "interrupt" it, do the thing in the validation callback and resume the process. That's the reason why it's not available. The Can I interest you on submitting a PR to the HttpClient library with that improvement? 😅 |
@josesimoes does sslverification really control the verification of the server certificate, or is it just a feature to skip checking the client certificate? |
@Alex-111 that skips validanting the SERVER certificate. It has nothing to do with client certificates. |
|
Description
When developing web apps for internal use, it is common to use self-signed certificates, or certificates not verified by a recognised CA authority.
In .net it is possible to use "ServerCertificateCustomValidationCallback" to catch certificate errors thrown by the framework and then handle this so that the user can suppress the problem as they wish (at their own risk of course!)
How to solve the problem
If something similar to this would be possible then that would be good.
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback += CertificateSelfValidation;
var httpClient = new HttpClien(handler);
private bool CertificateSelfValidation(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
//Example take from https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca5359
if (sslPolicyErrors == SslPolicyErrors.None)
{
return true;
}
}
Describe alternatives you've considered
No response
Aditional context
No response
The text was updated successfully, but these errors were encountered: