Https sites when third-party website to access https error: The request was aborted: Could not create SSL / TLS secure channel.

Https sites when third-party website to access https error:

The request was aborted:Could not create SSL/TLS secure channel.

 

Solution:

IF (Url.StartsWith ( " HTTPS " , StringComparison.OrdinalIgnoreCase)) // HTTPS request 
                { 
                    ServicePointManager.Expect100Continue = to true ;
                     // if it is above 4.5 can be used directly
                     // 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;
                }

 Callback:

    Private  static  BOOL CheckValidationResult ( Object SENDER, the X509Certificate Certificate, X509Chain catena alberghiera, SslPolicyErrors sslPolicyErrors) 
    { 
        // for certificate validation, always return to true 
        return  to true ; 
    }

 

Guess you like

Origin www.cnblogs.com/kevin860/p/12150043.html