TFS rest api Invoke-restmethod “The underlying connection was closed: An unexpected error occurred on a receive”

大兔子大兔子 提交于 2020-03-03 11:55:34

问题


I am trying to invoke TFS and/or Azure DevOps REST Api in one of the powershell tasks in release pipeline in Azure DevOps. I tried running the same rest api code in two different servers (w/ azure pipeline agent installed) but one of them is working and one of them returns "The underlying connection was closed: An unexpected error occurred on a receive..". The two agent servers have both tls 1.1 and 1.2 enabled. the working server has powershell v 4.0 and the server that returns error has v5.0.

When I ran "[Net.ServicePointManager]::SecurityProtocol," both servers returned ssl3, Tls.

I have a workaround for the server that returns error by using [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 but I would like to know why I need to force using TLS 1.2 on one of the servers and not the others when they seem have same TLS configuration.


回答1:


Without knowing much else of the server, a registry key setting might be set on that server with PowerShell V4.

You can check the following reg keys to see if they have the following properties:

'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord


'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord 


来源:https://stackoverflow.com/questions/57048820/tfs-rest-api-invoke-restmethod-the-underlying-connection-was-closed-an-unexpec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!