今天在用powershell 的Invoke-WebRequest下载文件时报错了:
Invoke-WebRequest : 请求被中止: 未能创建 SSL/TLS 安全通道。
很快在网上找到了答案:
《PAYPAL 支付,sandbox测试的时候遇到异常:请求被中止: 未能创建 SSL/TLS 安全通道,以及解决方法》
只是加了一行代码:
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
不过是用csharp代码写的,powershell的写法如下,即解决问题:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
参考资料:
https://stackoverflow.com/questions/41618766/powershell-invoke-webrequest-fails-with-ssl-tls-secure-channel