Я пытаюсь вызвать API отдыха на устройстве, однако оно использует самозаверяющий сертификат для сокета https.Я попытался изменить следующее в PowerShell
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
Но при выполнении моего вызова, используя следующее,
$uri = 'https://hostname/api/config'
$headers = @{"Authorization"="token apitokengoeshere"}
try {
Invoke-RestMethod -Uri $uri -Headers $headers
}
catch {
$_.Exception |format-list -force
}
, но я все еще получаю следующую ошибку
Status : SendFailure
Response :
Message : The underlying connection was closed: An unexpected
error occurred on a send.
Data : {}
InnerException : System.IO.IOException: Unable to read data from the
transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
TargetSite : System.Net.WebResponse
GetResponse(System.Net.WebRequest)
StackTrace : at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
HelpLink :
Source : Microsoft.PowerShell.Commands.Utility
HResult : -2146233079
Я даже пытался установить модуль Tunable-SSL Powershell, как упоминалось в блоге, упомянутом Здесь в предыдущем вопросе.