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

来源:互联网 发布:电火花成型加工编程 编辑:程序博客网 时间:2024/06/03 09:04

今天在用powershell 的Invoke-WebRequest下载文件时报错了:

Invoke-WebRequest : 请求被中止: 未能创建 SSL/TLS 安全通道。

很快在网上找到了答案:
[《PAYPAL 支付,sandbox测试的时候遇到异常:请求被中止: 未能创建 SSL/TLS 安全通道,以及解决方法》](
http://blog.csdn.net/tsl196865614/article/details/52813275)

只是加了一行代码:

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

阅读全文
0 0
原创粉丝点击