powershell强制ssl版本3获取请求

use*_*209 4 powershell

我想知道如果其中一个powershell,C#专家可以在Windows上使用[System.Net.WebRequest]在webrequest期间如何强制使用Sslv3

我想将以下C#代码转换为Powershell的等价代码:

 ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
Run Code Online (Sandbox Code Playgroud)

我尝试将以下代码添加到我的脚本,但得到并且错误,术语"Net.SecurityProtocolType.ssl3"未被识别为cmdlet,脚本文件,函数的名称.以下是我在代码中使用的内容:

 [System.Net.ServicePointManager]::SecurityProtocol = Net.SecurityProtocolType.ssl3
Run Code Online (Sandbox Code Playgroud)

感谢您的帮助!

Aar*_*sen 9

枚举需要扩展类型方括号语法:

 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::ssl3
Run Code Online (Sandbox Code Playgroud)

您也可以让PowerShell为您投射:

[Net.ServicePointManager]::SecurityProtocol = 'ssl3'
Run Code Online (Sandbox Code Playgroud)

  • 虽然我需要强制使用 TLS 1.2,但此答案有助于找到我的解决方案,谢谢!BigCommerce API 需要 TLS 1.2,我在 PowerShell 中收到以下错误。System.Net.WebException:基础连接已关闭:发送时发生意外错误。---> System.IO.IOException:身份验证失败,因为远程方已关闭传输流。 (2认同)