Added Service Point Manager call to force Tls12. (#6310)

Calls [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 during bootstrap to download PowerShell core to avoid an error.
This commit is contained in:
Donovan Brown authored and Travis Plunk committed 2018-03-09 15:12:05 -08:00
1 parent d623c9f10c
commit 489f8336b1
1 file changed
+8
+8
View File
@@ -91,6 +91,11 @@ $architecture = if (-not $IsWinEnv) {
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
New-Item -ItemType Directory -Path $tempDir -Force > $null
try {
# Setting Tls to 12 to prevent the Invoke-WebRequest : The request was
# aborted: Could not create SSL/TLS secure channel. error.
$originalValue = [Net.ServicePointManager]::SecurityProtocol
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
if ($Daily) {
if (-not (Get-Module -Name PackageManagement -ListAvailable)) {
throw "PackageManagement module is required to install daily PowerShell Core."
@@ -227,5 +232,8 @@ try {
Write-Host "Please restart pwsh" -ForegroundColor Magenta
}
} finally {
# Restore original value
[Net.ServicePointManager]::SecurityProtocol = $originalValue
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
}