From 8aa512ada2f76a3a7394826dbd10b4b603d612f4 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Fri, 5 Oct 2018 21:45:38 +0100 Subject: [PATCH] Restore security protocol and use better version using -bor without breaking HTTPS --- tools/appveyor.psm1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 130488f8d..9c94999ed 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -30,8 +30,15 @@ function Invoke-AppVeyorInstall { $globalDotJson = Get-Content (Join-Path $PSScriptRoot '..\global.json') -Raw | ConvertFrom-Json $dotNetCoreSDKVersion = $globalDotJson.sdk.version if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion))) { - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # https://github.com/dotnet/announcements/issues/77 - Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 + try { + $originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol + # To avoid SSL error, see https://github.com/dotnet/announcements/issues/77 and https://github.com/PowerShell/PowerShell/pull/6236/files + [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 + Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 + } + finally { + [Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol + } .\dotnet-install.ps1 -Version $dotNetCoreSDKVersion Remove-Item .\dotnet-install.ps1 }