From be245d5dfac9fba6fdf9bb481a525059d15c7554 Mon Sep 17 00:00:00 2001 From: Babil Golam Sarwar Date: Wed, 11 Jul 2018 11:37:34 +1000 Subject: [PATCH] Add TLS 1.1/1.2 support to Invoke-WebRequest --- native/win_install.ps1 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/native/win_install.ps1 b/native/win_install.ps1 index bda53d72..89bb3d7b 100644 --- a/native/win_install.ps1 +++ b/native/win_install.ps1 @@ -43,6 +43,11 @@ $global:NoPython= $NoPython $global:InstallDirBase = $InstallDirBase.Trim() $global:DebugDirBase = $DebugDirBase.Trim() +function Set-TlsVersion() { + [Net.ServicePointManager]::SecurityProtocol = + [Net.SecurityProtocolType]::Tls12 -bOr ` + [Net.SecurityProtocolType]::Tls11 +} function Get-PythonVersionStatus() { try { $pythonVersion = Invoke-Expression ` @@ -231,10 +236,15 @@ function Set-MessengerBin() { Write-Host "[+] Downloading $messengerBinUri ..." try { + Set-TlsVersion Invoke-WebRequest ` -Uri $messengerBinUri ` -OutFile $messengerBinPath } catch { + Write-Host ` + "Invoke-WebRequest Exception:" ` + $_.Exception.GetType().FullName, $_.Exception.Message + Write-Host ` "Invoke-WebRequest StatusCode:" ` $_.Exception.Response.StatusCode.value__ @@ -352,6 +362,7 @@ function Set-MessengerManifest() { Write-Host "[+] Downloading $messengerManifestUri ..." try { + Set-TlsVersion Invoke-WebRequest ` -Uri $messengerManifestUri ` -OutFile $messengerManifestPath @@ -495,8 +506,8 @@ function Set-MessengerInstall() { Write-Host " - Python 3 not found, will use EXE ..." $global:NoPython = $true } else { - $pythonPath = Get-Command "py" ` - | Select-Object -ExpandProperty "Source" + $pythonPath = Get-Command "py" ` + | Select-Object -ExpandProperty "Source" Write-Host " - Python 3 found at: $pythonPath" }