Had a certificate expire at 8PM EST tonight on a critical project I was supposed to demo, wasn’t going to stop me… lots of articles don’t really go over how to do this now on .NET Core 1.0, so lets cover the code to do so:
using (var httpClientHandler = new HttpClientHandler()) { httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return true; }; using (var client = new HttpClient(httpClientHandler)) { // Make request here. } }
Pretty simple, really.
Thank you for writing this, I have been searching for how to do this all day for our development environment, as the old .Net way of doing it doesn’t work anymore.
Thank you very much William Roush. You saved my lot of time. Grate post…..
i tried that and i get:
Severity Code Description Project File Line Suppression State
Error CS1061 ‘HttpClientHandler’ does not contain a definition for ‘ServerCertificateCustomValidationCallback’ and no accessible extension method ‘ServerCertificateCustomValidationCallback’ accepting a first argument of type ‘HttpClientHandler’ could be found (are you missing a using directive or an assembly reference?) InfrastructureManagerClientService C:\Users\blabla\Source\Repos\blabla\blabla\blabla.cs 79 Active
did ‘they’ remove this definition?
Thank alot. Sometimes stackoverflow and google are not helpful at all