切换TLS1.2后,C#请求报错:请求被中止: 未能创建 SSL/TLS 安全通道

itlao6 原创 工具&方法 开发&源码评论421字数 561阅读1分52秒阅读模式

最近因为安全性要求:将所有域名TLS版本限制为1.2才能访问,禁用了之前的1.0和1.1。但是在.net后台进行请求时报错“请求被中止: 未能创建 SSL/TLS 安全通道”

通过以下方式解决:文章源自IT老刘-https://itlao6.com/6226.html

ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; 文章源自IT老刘-https://itlao6.com/6226.html

具体原理参考微软官方文档:文章源自IT老刘-https://itlao6.com/6226.htmlhttps://docs.microsoft.com/zh-cn/dotnet/api/system.net.servicepointmanager.securityprotocol?view=net-5.0 文章源自IT老刘-https://itlao6.com/6226.htmlhttps://support.microsoft.com/zh-cn/topic/%E6%97%A0%E6%B3%95%E8%BF%9E%E6%8E%A5%E5%88%B0%E4%B8%80%E5%8F%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%8D%87%E7%BA%A7%E5%88%B0-net-framework-4-6-%E5%90%8E%E4%BD%BF%E7%94%A8-servicepointmanager-%E6%88%96-sslstream-api-1e3a9788-ab0d-7794-204b-6c4678bc5ed5文章源自IT老刘-https://itlao6.com/6226.html

文章源自IT老刘-https://itlao6.com/6226.html文章源自IT老刘-https://itlao6.com/6226.html
weinxin
我的微信公众号
微信扫一扫关注公众号,不定时更新
itlao6
  • 本文由 发表于 2021年 8月 15日 21:35:07
  • 转载请务必保留本文链接:https://itlao6.com/6226.html
评论  0  访客  0
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定