VMware Cloud Community
an648
Enthusiast
Enthusiast
Jump to solution

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

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
LucD
Leadership
Leadership
Jump to solution

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
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
an648
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

What does Get-PowerCLIConfiguration return?


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

Reply
0 Kudos
an648
Enthusiast
Enthusiast
Jump to solution

Please find the output

Output_PowerCLI1.PNG

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

mthagedo
Contributor
Contributor
Jump to solution

I'm getting the same error with Powervra 4.1.1

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos