Skip to content

Commit 489f833

Browse files
DarqueWarriorTravisEz13
authored andcommitted
Added Service Point Manager call to force Tls12. (PowerShell#6310)
Calls [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 during bootstrap to download PowerShell core to avoid an error.
1 parent d623c9f commit 489f833

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tools/install-powershell.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ $architecture = if (-not $IsWinEnv) {
9191
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
9292
New-Item -ItemType Directory -Path $tempDir -Force > $null
9393
try {
94+
# Setting Tls to 12 to prevent the Invoke-WebRequest : The request was
95+
# aborted: Could not create SSL/TLS secure channel. error.
96+
$originalValue = [Net.ServicePointManager]::SecurityProtocol
97+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
98+
9499
if ($Daily) {
95100
if (-not (Get-Module -Name PackageManagement -ListAvailable)) {
96101
throw "PackageManagement module is required to install daily PowerShell Core."
@@ -227,5 +232,8 @@ try {
227232
Write-Host "Please restart pwsh" -ForegroundColor Magenta
228233
}
229234
} finally {
235+
# Restore original value
236+
[Net.ServicePointManager]::SecurityProtocol = $originalValue
237+
230238
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
231239
}

0 commit comments

Comments
 (0)