I am trying to connect to a localhost REST server using powershell Invoke-RestMethod cmdlet as follows:
Invoke-RestMethod -Uri "https://localhost:port/xxx/xxx/" -CertificateThumbprint "thumbprint of my client certificate"
Whenever I run this command I always get this error Invoke-RestMethod : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
I have the necessary server certificate and client certificate installed. Powershell client certificate is installed in the Currentuser store. The certification authority cert is also added to the "Trusted root certification authority".
Can someone please explain why this error? I am not looking for tricks to ignore cert errors, I am trying to understand what's wrong with Powershell. If I use IE then it works just fine.
Thanks.