pcgeek86 / PSGitHub

This PowerShell module contains commands to manage GitHub through its REST API.
MIT License
182 stars 39 forks source link

The request was aborted: Could not create SSL/TLS secure channel. #40

Closed czhang03 closed 6 years ago

czhang03 commented 6 years ago

Before submitting your issue for the PSGitHub project, please take a moment to provide the following details:

I am not sure this is your fault, but I have been encountering The following error:

Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel.

I tried the following operation:

❯ Invoke-RestMethod https://api.github.com/repos/pcgeek86/PSGitHub

Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel.
At line:1 char:1
+ Invoke-RestMethod https://api.github.com/repos/pcgeek86/PSGitHub
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

I also tried other sites:

❯ Invoke-RestMethod https://xkcd.com/614/info.0.json
Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel.
At line:1 char:1
+ Invoke-RestMethod https://xkcd.com/614/info.0.json
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

I don't know is my computer is going crazy or is there anything wrong.

czhang03 commented 6 years ago

running the following line fixes this problem:

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;

I don't know if this is a good fix.

reference: https://virtualbrakeman.wordpress.com/2016/03/20/powershell-could-not-create-ssltls-secure-channel/