Skip to content

Save & restore the state of [Net.ServicePointManager]::SecurityProtocol #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5 changes: 5 additions & 0 deletions GitHubCore.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ function Invoke-GHRestMethod
}

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

try
{
Expand Down Expand Up @@ -540,6 +541,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