Skip to content

Commit

Permalink
(GH-958) If SSLv3 in Posh v2 Fails, Use Original
Browse files Browse the repository at this point in the history
When original protocol fails in PowerShell v2, `Get-ChocolateyWebFile`
will switch to try the older SSL v3 protocol. When that also fails, the
original protocol should be reinstated.
  • Loading branch information
ferventcoder committed Sep 12, 2016
1 parent 66b636a commit 660eef2
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,13 @@ param(
if ($host.Version -lt (new-object 'Version' 3,0)) {
Write-Debug "Converting Security Protocol to SSL3 only for Powershell v2"
# this should last for the entire duration
$originalProtocol = [System.Net.ServicePointManager]::SecurityProtocol
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Ssl3
try {
$headers = Get-WebHeaders $url -ErrorAction "Stop"
} catch {
Write-Host "Attempt to get headers for $url failed.`n $($_.Exception.Message)"
[System.Net.ServicePointManager]::SecurityProtocol = $originalProtocol
}
} else {
Write-Host "Attempt to get headers for $url failed.`n $($_.Exception.Message)"
Expand Down

0 comments on commit 660eef2

Please sign in to comment.