Resolution of request suspension: unable to establish SSL/TLS Security channel (the request was aborted: cocould not create SSL/TLS Secure Channel)

Source: Internet
Author: User

When I used httpwebrequest to access other websites, the error "the request was aborted: unable to establish SSL/TLS Secure Channel" appeared. So goog and Baidu compared the problem. The answer is servicepointmanager. servercertificatevalidationcallback write delegate

Public responsemodel gethtml (string URL) {servicepointmanager. servercertificatevalidationcallback = validateservercertificate; httpwebrequest request = (httpwebrequest) webrequest. create (URL);} private bool validateservercertificate (Object sender, x509certificate certificate, x509chain chain, sslpolicyerrors) {return true ;}

However, this method does not work for me. The error still persists.

The final solution is to execute the statement servicepointmanager. securityprotocol = securityprotocoltype. ssl3; before accessing the URL.

Public responsemodel gethtml (string URL) {servicepointmanager. securityprotocol = securityprotocoltype. ssl3; httpwebrequest request = (httpwebrequest) webrequest. Create (URL );}

The whole world is much quieter. Haha

 

 

 

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.