c# 中HttpClient访问Https网站

c# 中HttpClient访问Https网站,加入如下代码:

handler = new HttpClientHandler() ;
handler.AllowAutoRedirect = true;
handler.UseCookies = true;
handler.CookieContainer = cookies;


System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

或者:
handler.ClientCertificateOptions = ClientCertificateOption.Automatic;

 

httpClient = new HttpClient(handler);

posted @ 2019-03-25 10:21  94cool  阅读(6116)  评论(2编辑  收藏  举报