Skip to content

Commit

Permalink
Save & restore the state of [Net.ServicePointManager]::SecurityProtoc…
Browse files Browse the repository at this point in the history
…ol (#240)

[Net.ServicePointManager]::SecurityProtocol is a global configuration that was being modified during the execution of `Invoke-GHRestMethod`.  With this change, the global state will be cached before the change and restored immediately afterwards.

Fixes #230
  • Loading branch information
giuseppecampanelli authored Jun 18, 2020
1 parent 17f6122 commit 618398e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions GitHubCore.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ function Invoke-GHRestMethod
}

$NoStatus = Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus -ConfigValueName DefaultNoStatus
$originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol

try
{
Expand Down Expand Up @@ -560,6 +561,10 @@ function Invoke-GHRestMethod
Set-TelemetryException -Exception $ex -ErrorBucket $errorBucket -Properties $localTelemetryProperties -NoStatus:$NoStatus
throw $newLineOutput
}
finally
{
[Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol
}
}

function Invoke-GHRestMethodMultipleResult
Expand Down

0 comments on commit 618398e

Please sign in to comment.