powershell 执行下载的时候。报错:“irm : 请求被中止: 未能创建 SSL/TLS 安全通道“。
此时系统,所有的网络下载 经过https安全加密方式的TLS请求都会报错。因为加密版本不匹配的问题。
可以通过以下命令,查看当前加密协议,一般要新协议 Tls12 :
- [System.Net.ServicePointManager]::SecurityProtocol
-
- # fix ssl in tyy win10 server 2016
- [System.Net.ServicePointManager]::SecurityProtocol += [System.Net.SecurityProtocolType]::Tls12;
-
[.NET Framework 中的传输层安全性 (TLS) 最佳做法 - .NET Framework | Microsoft Learn](https://learn.microsoft.com/zh-cn/dotnet/framework/network-programming/tls)
以下 .REG 文件将注册表项及其变量设置为其最安全的值:
- Windows Registry Editor Version 5.00
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v2.0.50727]
- "SystemDefaultTlsVersions"=dword:00000001
- "SchUseStrongCrypto"=dword:00000001
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v4.0.30319]
- "SystemDefaultTlsVersions"=dword:00000001
- "SchUseStrongCrypto"=dword:00000001
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]
- "SystemDefaultTlsVersions"=dword:00000001
- "SchUseStrongCrypto"=dword:00000001
-
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
- "SystemDefaultTlsVersions"=dword:00000001
- "SchUseStrongCrypto"=dword:00000001
-