仅限于非网络异常情况
解决方案:
在创建访问请求前增加TLS1.1和1.2支持
.net 4.5
System.Net.ServicePointManager.SecurityProtocol |= (SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12);
或者
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
.net 4.0
ServicePointManager.SecurityProtocol |= (SecurityProtocolType)0x300 | (SecurityProtocolType)0xc00; //增加TLS1.1和1.2支持
原因:
//.net 4.0/4.5默认值:SecurityProtocolType.Tls | SecurityProtocolType.Ssl3
//.net 4.6/4.7默认值:SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12
在net framework-4.5
当通过 HTTPClient、HttpWebRequest、FTPClient、SmtpClient、SslStream 等 API 使用 TLS/SSL 的应用程序
或者一些包的底层依赖于以上所述时,且访问的目标URL为HTTPS的,将可能会出现此类问题
例如SendGrid等底层依赖于网络的包