-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
As stated in Example 2 here,
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $True }has no effect on Invoke-WebRequest or Invoke-RestMethod, establishing the TLS session will still fail if the remote presents a self-signed certificate.
PS> [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $True }
PS> Invoke-RestMethod -URI https://selfsigned.badssl.com
Invoke-RestMethod : The underlying connection was closed:
An unexpected error occurred on a send.
At line:1 char:1
+ invoke-restmethod -uri https://selfsigned.badssl.com
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest)
[Invoke-RestMethod],WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,
Microsoft.PowerShell.Commands.InvokeRestMethodCommandPS> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.15063.138
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.138
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1Looks like it only works when calling straight into the assembly:
$apiReq = [System.Net.HttpWebRequest]::CreateHttp($url)
$apiRes = $apiReq.GetResponse()
The TLS handshake is successful now.
This is not kosher, definitely needs to be addressed.
Metadata
Metadata
Assignees
Labels
No labels