C # access to HTTPS failed to create SSL/TLS secure channel

Source: Internet
Author: User

C # Access HTTPS request aborted: Failed to create SSL/TLS secure channel (Could not-create SSL/TLS secure Channels)

General GetResponse can access HTTPS directly, if not add callback:

Servicepointmanager.servercertificatevalidationcallback = new System.Net.Security.RemoteCertificateValidationCallback (CheckValidationResult);
Not yet, added: Servicepointmanager.securityprotocol = SECURITYPROTOCOLTYPE.SSL3;

           public string gethttpwebresponse (string url, string postdata, String code = "Utf-8") {Servic            Epointmanager.securityprotocol = SECURITYPROTOCOLTYPE.SSL3; Servicepointmanager.servercertificatevalidationcallback = new            System.Net.Security.RemoteCertificateValidationCallback (CheckValidationResult);            HttpWebRequest request = (HttpWebRequest) httpwebrequest.create (URL);            HttpWebResponse response = null; try {response = (HttpWebResponse) request.                GetResponse (); using (StreamReader reader = new StreamReader (response. GetResponseStream (), encoding.getencoding (code)) {return reader.                ReadToEnd ();            }} catch (WebException e) {return e.message; The finally {if (response! = NULL) response.            Close (); }} public static bool CheckvAlidationresult (object sender, X509Certificate certificate, X509chain chain, sslpolicyerrors errors) {R        Eturn true; }

  

C # access to HTTPS failed to create SSL/TLS secure channel

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.