-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fixed tls issues #6905
fixed tls issues #6905
Conversation
@@ -5,16 +5,20 @@ function Add-Tls12InSession { | |||
param() | |||
|
|||
try { | |||
if ([Net.ServicePointManager]::SecurityProtocol -notcontains 'Tls12') { | |||
[Net.ServicePointManager]::SecurityProtocol += [Net.SecurityProtocolType]3072 | |||
if ([Net.ServicePointManager]::SecurityProtocol.ToString().Split(',').Trim() -notcontains 'Tls12') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be tostring().Trim().split(',')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split(',').Trim() - this will trim invidual values. I think this is fine here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Ajay is right. This should be fine.
@@ -5,16 +5,20 @@ function Add-Tls12InSession { | |||
param() | |||
|
|||
try { | |||
if ([Net.ServicePointManager]::SecurityProtocol -notcontains 'Tls12') { | |||
[Net.ServicePointManager]::SecurityProtocol += [Net.SecurityProtocolType]3072 | |||
if ([Net.ServicePointManager]::SecurityProtocol.ToString().Split(',').Trim() -notcontains 'Tls12') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use the HasFlag() method of Enum class? The if condition would be:
if ( -Not [System.Net.ServicePointManager]::SecurityProtocol.HasFlag([System.Net.SecurityProtocolType]::Tls12) )
Refer: https://msdn.microsoft.com/en-us/library/system.enum.hasflag(v=vs.110).aspx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasFlag is available since .Net 4.0 only. Let's not take that dependency.
$securityProtocol+=[Net.ServicePointManager]::SecurityProtocol | ||
$securityProtocol+=[Net.SecurityProtocolType]3072 | ||
[Net.ServicePointManager]::SecurityProtocol=$securityProtocol | ||
|
||
Write-Host (Get-VstsLocString -Key TLS12AddedInSession) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to expose this as a user facing message ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We'll let the user know that we have added TLS 1.2 in session and that the network calls might use this protocol.
Shouldn't this have been part of the PowerShell execution handler? Or at least part of the task-lib? |
#6891
#6895