首页 > Web开发 > 详细

http忽略证书错误

时间:2020-03-16 00:53:13      阅读:76      评论:0      收藏:0      [点我收藏+]

使用HttpClient请求https的url,但又没有本地证书,这时候可以用下面的方法忽略警告

  var httpclientHandler = new HttpClientHandler();
    httpclientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, error) => true;
    var httpClient = new HttpClient(httpclientHandler);
.nerCore IHttpClentFactory下
 //注入HttpClient,并且全局禁用cookie
        serviceCollection.AddHttpClient(typeof(ServiceProxy).FullName)
            .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
            {
                CookieContainer = new CookieContainer(),
                UseCookies = false
            });

http忽略证书错误

原文:https://www.cnblogs.com/sadsadfd/p/12501283.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!