I'm trying to intercept the validation of the returned server certificates in a .net framework application. I came with two solutions:
Use
HttpClientHandler.ServerCertificateValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) =>{ my implementation}Use
ServicePointManager.ServerCertificateValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) =>{ my implementation}
Is there advantage for the use of one on another?
From the article it says
We don't recommend that you use the ServicePointManager class for new development. Instead, use the System.Net.Http.HttpClient class.
Is there any reason for that , other than ServicePointManager not being used in .net Core?
ServicePointManagerseems to have a few methods marked as obsolete: https://learn.microsoft.com/en-us/dotnet/api/system.net.servicepointmanager?view=net-6.0#:~:text=this%20ServicePointManager%20object.-,Methods,-Equals(Object)Looks like new classed with updated methods now exist.
ServicePointManageris probably being kept around largely for compatibility with old versions.