diff options
author | Dave <steve-dave@users.noreply.github.com> | 2017-08-11 11:00:34 +1000 |
---|---|---|
committer | Jordan Borean <jborean93@gmail.com> | 2017-08-30 16:51:16 +1000 |
commit | 8db83172d362e6b07121f3e1a0986210a8c24ab2 (patch) | |
tree | 1edecd2897b78022e62d853d9d7965d5161f2d21 | |
parent | c3917f395ace659105d2d977853948f8e180387f (diff) | |
download | ansible-8db83172d362e6b07121f3e1a0986210a8c24ab2.tar.gz |
win_get_url.ps1 - enable TLS1.1/TLS1.2 if they're available but disabled (#26833)
(cherry picked from commit 4cec83471c47af37a7467afc41120354214cc5dc)
-rw-r--r-- | lib/ansible/modules/windows/win_get_url.ps1 | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/ansible/modules/windows/win_get_url.ps1 b/lib/ansible/modules/windows/win_get_url.ps1 index bc1b669d0e..e1b9e669d3 100644 --- a/lib/ansible/modules/windows/win_get_url.ps1 +++ b/lib/ansible/modules/windows/win_get_url.ps1 @@ -71,6 +71,15 @@ Function Download-File($result, $url, $dest, $username, $password, $proxy_url, $ } +# Enable TLS1.1/TLS1.2 if they're available but disabled (eg. .NET 4.5) +$security_protcols = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::SystemDefault +if ([Net.SecurityProtocolType].GetMember("Tls11").Count -gt 0) { + $security_protcols = $security_protcols -bor [Net.SecurityProtocolType]::Tls11 +} +if ([Net.SecurityProtocolType].GetMember("Tls12").Count -gt 0) { + $security_protcols = $security_protcols -bor [Net.SecurityProtocolType]::Tls12 +} +[Net.ServicePointManager]::SecurityProtocol = $security_protcols If ($force -or -not (Test-Path -Path $dest)) { Download-File -result $result -url $url -dest $dest -username $username -password $password -proxy_url $proxy_url -proxy_username $proxy_username -proxy_password $proxy_password |