https网站访问第三方https网站时候报错: The request was aborted:Could not create SSL/TLS secure channel.

Posted kevin860

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
                }

 回调函数:

    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.的主要内容,如果未能解决你的问题,请参考以下文章

十二.HTTPS网站安全访问实践

HTTPS基本原理与应用

网站怎么实现https访问

https怎么获得证书,网站https访问证明弄?

火狐访问所有HTTPS网站显示连接不安全

Nginx 下面搭建https 网站