-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
I try to use RestPS module and could not connect to rest server with error:
Invoke-RestMethod : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel
If i use: [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
receive error: Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send
Server and client on the same host.
Server part: =========================================
$ServerCert = Get-ChildItem -Path Cert:\LocalMachine\My\ | Where-Object { $_.Subject -eq 'CN=Server.PowerShellDemo.io'}
$ServerParams = @{
RoutesFilePath = 'C:\RestPS\endpoints\RestPSRoutes.json'
Port = 8182
AppGuid = "d1495a62-411b-43e3-978f-eef3e710170d"
SSLThumbprint = $ServerCert.Thumbprint
VerificationType = 'VerifyRootCA'
}
Start-RestPSListener @ServerParams
Client part: ==========================================
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::Tls11 -bor [System.Net.SecurityProtocolType]::Tls
$ClientCert = Get-ChildItem -Path Cert:\LocalMachine\My\ | Where-Object { $_.Subject -eq 'CN=DemoClient.PowerShellDemo.io'}
$HttpsParams = @{
Uri = 'https://localhost:8182/process?name=powershell'
Method = 'Get'
Certificate = $ClientCert
UseBasicParsing = $true
}
Invoke-RestMethod @HttpsParams
Certificate generated from https://invoke-automation.blog/2018/09/16/creating-a-local-ssl-certificate-hierarchy-with-windows-powershell
What i do wrong?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels