Powershell Invoke-WebRequest The request was aborted Could not create SSL/TLS secure channel

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
2 min

banner

# Powershell Invoke-WebRequest The request was aborted Could not create SSL/TLS secure channel

The PowerShell Invoke-WebRequest error "The request was aborted: Could not create SSL/TLS secure channel" occurs because PowerShell uses TLS 1.0 when connecting to websites by default but the site you are making a request to requires TLS 1.1 or TLS 1.2 or SSLv3.

To solve the error, use the SecurityProtocol property to specify that all protocols are supported.

PowerShell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Ssl3 [Net.ServicePointManager]::SecurityProtocol = "Tls, Tls11, Tls12, Ssl3"

paste commands into powershell

You can copy the commands and paste them into PowerShell by pressing Ctrl + V.

Once you paste the commands, rerun your Invoke-WebRequest command.

PowerShell
Invoke-WebRequest -Uri https://nasa.gov

issue web request

When you run the command you might get another error:

  • "The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again."

If you get the error rerun the command with the -UseBasicParsing parameter.

shell
Invoke-WebRequest -Uri https://nasa.gov -UseBasicParsing

Setting the parameter is necessary on machines where Internet Explorer is not installed or configured.

Note that you should be able to only use a single command to specify that all security protocols should be used.

The following should be sufficient.

PowerShell
[Net.ServicePointManager]::SecurityProtocol = "Tls, Tls11, Tls12, Ssl3" Invoke-WebRequest -Uri https://nasa.gov -UseBasicParsing

enable all protocols for http request

If you decide to use the alternative, more verbose command, you can wrap it into multiple multiple lines by ending each line with a backtick `.

PowerShell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor ` [Net.SecurityProtocolType]::Tls11 -bor ` [Net.SecurityProtocolType]::Tls -bor ` [Net.SecurityProtocolType]::Ssl3 Invoke-WebRequest -Uri https://nasa.gov -UseBasicParsing

wrap command that enables all protocols into multiple lines

The Invoke-WebRequest PowerShell command is used to get the content of a web page on the internet.

You can view examples of using the command in this section of the Microsoft docs.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.