zl程序教程

您现在的位置是:首页 >  后端

当前栏目

c# 中HttpClient访问Https网站

c#HTTPS网站 访问 httpclient
2023-09-11 14:14:13 时间

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);

转载于:https://www.cnblogs.com/94cool/p/10592262.html