powershell 请求被中止: 未能创建 SSL/TLS 安全通道

1. powershell 请求被中止: 未能创建 SSL/TLS 安全通道

英文搜索关键词 : the request was aborted could not create ssl/tls (net 4.6)

statckoverflow 上面大多答案如下:

ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

也有用如下的 (强烈不建议使用)

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

原因:

  • Tls1.0 由于安全原因, 大部分 https 服务端已经不再建议支持。
  • .Net 4.5 及之前的版本, 不支持 Tls1.2 , SecurityProtocolType 这个枚举中没有 Tls12 这个项
  • Windows Server 2012 R2 中, 安装了. Net 4.6.x 或 4.7.x 后, 虽然系统支持, .Net 也支持, 但是默认的协商协议列表不包含 Tls1.2

解决方案 (PowerShell 脚本):

查看当前系统中默认启用的协商协议列表

[Net.ServicePointManager]::SecurityProtocol

打印出来的结果应该是不包含 Tls12 的, 我实测的 Win10 1603 以及 Windows Server 2012 R2 显示均为如下:

Ssl3, Tls

继续执行如下代码, 修改设置:

针对 64 位. Net:

Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord

针对 32 位. Net:

Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord

关闭 PowerShell 窗口, 打开一个新的 PowerShell 窗口, 执行以下代码

[Net.ServicePointManager]::SecurityProtocol

结果如下:

Tls, Tls11, Tls12, Tls13

重启之前受影响的. Net 应用程序即可生效。

  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云满笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值