chocolatey / cChoco

Community resource to manage Chocolatey
Apache License 2.0
154 stars 99 forks source link

cChoco resource to install Chocolatey does not work in powershell 7.4.1 due to Ssl3 presumption #182

Open coderjoe opened 5 months ago

coderjoe commented 5 months ago

Checklist

What You Are Seeing?

When attempting to install chocolatey using the cChocoInstaller resource and the cChoco package version 2.6.0 in pwsh 7.4.1 the resource fails with the following error:

Resource [InstallChoco] 'Set' error: Exception setting "SecurityProtocol": "The requested security protocol is not supported."

What is Expected?

The resource should run as expected.

How Did You Get This To Happen?

  1. I created the DSC script at the end of this list.
  2. I tried to run the DSC script
  3. I received the error

The relevant DSC configuration:

Configuration CreateDscConfiguration
{
  Import-DscResource -ModuleName cChoco -ModuleVersion 2.6.0.0  # See: https://github.com/chocolatey/cChoco

  Node localhost
  {
    cChocoInstaller InstallChoco {
      InstallDir = "C:\ProgramData\chocolatey"
    }
  }
}

System Details

Installed Packages

-na- chocolatey is not yet installed

Output Log

-na- the chocolatey cli isn't able to be installed

Additional Context

Please note that this is different from the existing issue #173 as we are not trying to use DSCv3. We're just using Powershell 7.4.1 with DSCv2. All of our legacy DSC scripts so far work, but this error is preventing our cChoco installation.

I believe the problem to be related to this line in the cChocoInstaller resource which presumes that Ssl3 is available. It was deprecated and attempting to run that line in powershell 7.4.1 produces the error expected.

It will likely have to look up the current running Powershell version and only use Ssl3 in the correct version similar to this change in chocolatey itself: https://github.com/chocolatey/choco/issues/1623

coderjoe commented 5 months ago

It appears this problem happens all the way back in Powershell 6 due to the SSLv3 deprecation/removal. I'm going to take a stab at a PR since this is affecting many of our scripts.