//请求前设置一下使用的安全协议类型 System.Net
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)){
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) =>
{
return true; //总是接受
});
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
使用HttpWebRequest请求https链接时,无法访问的问题,设置ServicePointManager.SecurityProtocol安全协议
最新推荐文章于 2024-08-22 11:28:30 发布