powershell forcing ssl version 3 for get requests
Asked Answered
V

2

5

I am wondering if one of the powershell, C# gurus can please shed some light on the how to force Sslv3 during a webrequest on Windows using [System.Net.WebRequest]

I would like to convert the following C# code to Powershell's equivalent:

 ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

I tried adding the following code to my script but get and error that the term "Net.SecurityProtocolType.ssl3" is not recognized as the name of a cmdlet, scriptfile, function. Below is what I used in my code:

 [System.Net.ServicePointManager]::SecurityProtocol = Net.SecurityProtocolType.ssl3

Thanks for all the help!

Vera answered 12/6, 2012 at 16:13 Comment(0)
O
11

Enumerations require the extended type square bracket syntax:

 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::ssl3

You could also just let PowerShell cast it for you:

[Net.ServicePointManager]::SecurityProtocol = 'ssl3'
Opulence answered 12/6, 2012 at 19:16 Comment(4)
Slightly shorter way using a string: [Net.ServicePointManager]::SecurityProtocol = 'Ssl3'Gonagle
While I needed to force TLS 1.2 this answer was helpful in finding my solution, thanks! The BigCommerce API requires TLS 1.2 and I was getting the following error in PowerShell. System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream.Mich
How can I print out all available protocols?Flatboat
All protocols are listed on learn.microsoft.com/en-us/dotnet/api/…Escribe
D
0

'ssl3' is deprecated, and not supported in PowerShell anymore.

Dextroglucose answered 11/10 at 12:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.