博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
偶尔遇到的“The request was aborted:Could not create SSL/TLS secure channel.”怎么解决?
阅读量:7000 次
发布时间:2019-06-27

本文共 554 字,大约阅读时间需要 1 分钟。

if
(url.StartsWith(
"https"
, StringComparison.OrdinalIgnoreCase))
///https请求
{
    
ServicePointManager.Expect100Continue =
true
;
    
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
//SSL3协议替换成TLS协议
    
ServicePointManager.ServerCertificateValidationCallback =
new
RemoteCertificateValidationCallback(CheckValidationResult);
    
webRequest = WebRequest.Create(url)
as
HttpWebRequest;
    
webRequest.ProtocolVersion = HttpVersion.Version10;
}
else
{
    
webRequest = WebRequest.Create(url)
as
HttpWebRequest;
}

转载于:https://www.cnblogs.com/only-yu/p/7101102.html

你可能感兴趣的文章