Skip to content

Commit 5bf790a

Browse files
committed
(chocolatey#2902) Ensure PowerShell tasks use SystemDefault TLS
In chocolatey#3123 we changed our default TLS handling to defer to SystemDefault. Subsequently, we have discovered that some versions of Windows PowerShell are explicitly setting the TLS settings away from the SystemDefault. As covered in the previous PR, this is a potential security hazard, and also complicates matters for users in terms of being able to communicate with servers that need TLS 1.3 for example. Rather than tolerate the default from Windows PowerShell, we can inject our own default setting here for our PowerShell host similar to how we clear out culture settings before running PowerShell tasks.
1 parent 29a0163 commit 5bf790a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/chocolatey/infrastructure.app/services/PowershellService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public string WrapScriptWithModule(string script, IEnumerable<string> hookPreScr
185185
// many issues in existing packages, including upgrading
186186
// Chocolatey from older POSH client due to log errors
187187
//$ErrorActionPreference = 'Stop';
188-
return "[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name '{0}';{2} & '{1}' {3}"
188+
return "[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = '';[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::SystemDefault; & import-module -name '{0}';{2} & '{1}' {3}"
189189
.FormatWith(
190190
installerModule,
191191
scriptRunner,

0 commit comments

Comments
 (0)