Resolution of request suspension: unable to establish SSL/TLS Security channel (the request was aborted: cocould not create SSL/TLS Secure Channel)
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