首页 > 其他分享> > https网站访问第三方https网站时候报错: The request was aborted:Could not create SSL/TLS secure channel.
https网站访问第三方https网站时候报错: The request was aborted:Could not create SSL/TLS secure channel.
作者:互联网
https网站访问第三方https网站时候报错:
The request was aborted:Could not create SSL/TLS secure channel.
解决办法:
if(Url.StartsWith("https",StringComparison.OrdinalIgnoreCase))//https请求 { ServicePointManager.Expect100Continue = true; //如果是4.5以上版本可以直接使用 //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls // | SecurityProtocolType.Tls11 // | SecurityProtocolType.Tls // | SecurityProtocolType.Ssl3; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | (SecurityProtocolType)768 | (SecurityProtocolType)3072 | SecurityProtocolType.Ssl3; ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult); request = WebRequest.Create(Url_Temp) as HttpWebRequest; request.ProtocolVersion = HttpVersion.Version10; } else { request = WebRequest.Create(Url_Temp) as HttpWebRequest; }
标签:Tls,网站,request,ServicePointManager,Url,报错,https,SecurityProtocolType 来源: https://www.cnblogs.com/kevin860/p/12150043.html