X509Certificate certificate
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; }
回调函数:
private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { //为了通过证书验证,,总是返回true return true; }
https网站访谒第三方https网站时候报错: The request was aborted:Could not create SSL/TLS secure channel.
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/32254.html
- 上一篇:前端根本之CSS增补
- 下一篇: //是否禁用此插件 // allChunks: true