Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly use or support TLS1.2 #8

Closed
James3UK opened this issue Dec 20, 2021 · 1 comment
Closed

Explicitly use or support TLS1.2 #8

James3UK opened this issue Dec 20, 2021 · 1 comment

Comments

@James3UK
Copy link

James3UK commented Dec 20, 2021

On systems with TLS1.0 disabled I am getting this error:

Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At line:2 char:46
+ ... n = ([xml]((Invoke-WebRequest -UseBasicParsing -Uri:"$uri&action=info ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Adding the following line allows this to work:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

From Microsoft page:

https://docs.microsoft.com/en-us/security/engineering/solving-tls1-problem

Windows PowerShell uses .NET Framework 4.5, which does not include TLS 1.2 as an available protocol. To work around this, two solutions are available:

  1. Modify the script in question to include the following:
    [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;

  2. Add a system-wide registry key (e.g. via group policy) to any machine that needs to make TLS 1.2 connections from a .NET app. This will cause .NET to use the "System Default" TLS versions which adds TLS 1.2 as an available protocol AND it will allow the scripts to use future TLS Versions when the OS supports them. (e.g. TLS 1.3)

    reg add HKLM\SOFTWARE\Microsoft.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:64

    reg add HKLM\SOFTWARE\Microsoft.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:32

@pahuijbr
Copy link
Collaborator

pahuijbr commented Jun 3, 2022

This should be resolved in the latest version

@pahuijbr pahuijbr closed this as completed Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants