首页 > Web开发 > 详细

记一个netcore HttpClient的坑

时间:2018-12-30 23:38:19      阅读:4005      评论:0      收藏:0      [点我收藏+]

异常信息

The SSL connection could not be established, see inner exception ---> AuthenticationException: The remote certificate is invalid according to the validation procedure

 

背景

吐血大坑 N小时奋斗    issues  

技术分享图片

 

证书问题 原因不详  

       using (var client = new HttpClient())
            {
                
                client.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36");
                var html = (client.GetStringAsync("https://*****/").GetAwaiter().GetResult());
                Console.WriteLine(html);
                Console.ReadLine();
            }

  

我的环境 

system:centos7.2

netcore sdk 2.2

 

最后附上解决方案 

 export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0;dotnet build

 

感谢@晓晨 帮助 怎么清除证书

记一个netcore HttpClient的坑

原文:https://www.cnblogs.com/leoxjy/p/10201046.html

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