.Net Core HttpClient 忽略https证书提醒

在测试中经常会遇到请求一些https的url,但又没有本地证书,这时候可以用下面的方法忽略警告

    var httpclientHandler = new HttpClientHandler();
    httpclientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, error) => true;
    var httpClient = new HttpClient(httpclientHandler);
posted @ 2018-12-07 10:50 James.Ying 阅读(...) 评论(...) 编辑 收藏