Skip to content

Commit 27a6a9c

Browse files
authored
Merge pull request #611 from puppetlabs/check_for_tls_12
(MODULES-11334) Handle TLS 1.2 on older Windows systems
2 parents a5e5c0f + 9f0c6ea commit 27a6a9c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tasks/install_powershell.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,23 @@ $date_time_stamp = (Get-Date -format s) -replace ':', '-'
105105
$msi_dest = Join-Path ([System.IO.Path]::GetTempPath()) "puppet-agent-$arch.msi"
106106
$install_log = Join-Path ([System.IO.Path]::GetTempPath()) "$date_time_stamp-puppet-install.log"
107107

108+
# Most modern sites either require or are starting to require TLS 1.2.
109+
# On older Windows systems the default security protocols for PowerShell 5 are SSL3 and TLS 1.0.
110+
# When communicating with a site that has a higher TLS requirement requests will fail with the following error:
111+
# `Could not create SSL/TLS secure channel`.`
112+
# Set-Tls12 will add TLS 1.2 to the list of available security protocols if it is not already present.
113+
function Set-Tls12 {
114+
$Tls12 = [System.Net.SecurityProtocolType]::Tls12
115+
$CurrentSecurityProtocolList = [System.Net.ServicePointManager]::SecurityProtocol
116+
if (!$CurrentSecurityProtocolList.HasFlag($Tls12)) {
117+
[System.Net.ServicePointManager]::SecurityProtocol = $CurrentSecurityProtocolList, [System.Net.SecurityProtocolType]::Tls12
118+
}
119+
}
120+
108121
function DownloadPuppet {
109122
Write-Output "Downloading the Puppet Agent installer on $env:COMPUTERNAME..."
123+
Set-Tls12
124+
110125
$webclient = New-Object system.net.webclient
111126

112127
try {

0 commit comments

Comments
 (0)