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

fixed tls issues #6905

Merged
merged 1 commit into from
Apr 9, 2018
Merged

Conversation

rajatagrawal-dev
Copy link
Contributor

@rajatagrawal-dev rajatagrawal-dev commented Apr 9, 2018

@@ -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') {
Copy link
Member

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(',')

Copy link

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.

Copy link
Contributor Author

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') {
Copy link
Contributor

@asranja asranja Apr 9, 2018

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

Copy link

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

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)
Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

@jessehouwing
Copy link
Contributor

Shouldn't this have been part of the PowerShell execution handler? Or at least part of the task-lib?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants