Highlighted
Enthusiast
Enthusiast

Error while connecting to vRA 8.x- Invoke-RestMethod - Could not establish trust relationship for the SSL/TLS secure channel.

Jump to solution

Error while authenticating to vRA 8.x. How to eliminate Tls error ?

Invoke-RestMethod : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

+ $response = Invoke-RestMethod -Uri $url -Method Post -Headers $header ...

+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException

    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Please find the error screenshot

Output_PowerCLI.PNG

Any help would be appreciated

1 Solution

Accepted Solutions
Highlighted
User Moderator
User Moderator

That seems to be ok.

Out of curiosity, did you already try with the Connect-vRAServer function from the PowervRA module?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

7 Replies
Highlighted
User Moderator
User Moderator

Did you already try running the following before calling Invoke-RestMethod?

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls,

     [System.Net.SecurityProtocolType]::Tls11,

     [System.Net.SecurityProtocolType]::Tls12


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Highlighted
Enthusiast
Enthusiast

Yes, I am still facing the same issue.

Invoke-RestMethod : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS

secure channel.

At line:1 char:2

+  Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body $bo ...

+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc

   eption

    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

0 Kudos
Highlighted
User Moderator
User Moderator

What does Get-PowerCLIConfiguration return?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Highlighted
Enthusiast
Enthusiast

Please find the output

Output_PowerCLI1.PNG

0 Kudos
Highlighted
User Moderator
User Moderator

That seems to be ok.

Out of curiosity, did you already try with the Connect-vRAServer function from the PowervRA module?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Highlighted
Contributor
Contributor

I'm getting the same error with Powervra 4.1.1

0 Kudos
Highlighted
User Moderator
User Moderator

Since PowervRA is not part of PowerCLI but a community project, I suggest you open an Issue at the PowervRA repo.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos