Skip to content
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

Restore security protocol and use better version using -bor without breaking HTTPS #1076

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions tools/appveyor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ function Invoke-AppVeyorInstall {
$dotNetCoreSDKVersion = $globalDotJson.sdk.version
# don't try to run this script on linux - we have to do the negative check because IsLinux will be defined in core, but not windows
if (-not ((dotnet --version).StartsWith($dotNetCoreSDKVersion)) -and ! $IsLinux ) {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # https://github.com/dotnet/announcements/issues/77
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1
try {
$originalSecurityProtocol = [Net.ServicePointManager]::SecurityProtocol
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add an if condition that only changes if [Net.SecurityProtocolType]::Tls12 is not currently added.

Copy link
Collaborator Author

@bergmeister bergmeister Oct 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this what the bitwise operator -bor already does implicitly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my point is you could detect that no change is needed... not set $originalSecurityProtocol and not restore it if it is not set.

# To avoid SSL error, see https://github.com/dotnet/announcements/issues/77 and https://github.com/PowerShell/PowerShell/pull/6236/files
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1
}
finally {
[Net.ServicePointManager]::SecurityProtocol = $originalSecurityProtocol
}
.\dotnet-install.ps1 -Version $dotNetCoreSDKVersion
Remove-Item .\dotnet-install.ps1
}
Expand Down