问题
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