Linux中用HttpWebRequest或WebClient访问远程https路径

要想在Linux中用HttpWebRequest或WebClient访问远程https路径,需要作如下处理:
1,更新linux根证书(只需一次,在安装mono或安装jexus独立版后执行)
sudo mozroots --import --ask-remove
(独立版是:sudo /usr/jexus/mozroots --import --ask-remove)
2,在web程序中,在运行https请求之前的某个地方,比如Global.asax的Application_Start方法中添加一句:
System.Net.ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => { return true; };
posted @ 2017-07-29 09:54  网络蚂蚁  阅读(775)  评论(0编辑  收藏  举报