oauth2.0 MicrosoftOnline承载令牌检索在一台服务器上有效,但在另一台服务器上无效

1qczuiv0  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(201)

我有一个服务,已经成功地运行(仍然是)在Windows服务器上几年。
客户希望将容量增加一倍,因此希望在第二台Windows服务器上运行。但是,它失败了。
失败的部分是从Microsoft Online检索不记名令牌。
第二个服务器已经被确认能够在Soap UI中完成此操作
x1c 0d1x的数据
报告的例外情况的关键在于

System.AggregateException: One or more errors occurred. 
---> System.Net.Http.HttpRequestException: An error occurred while sending the request. 
---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. 
---> System.ComponentModel.Win32Exception: The client and server cannot communicate
, because they do not possess a common algorithm

字符串
失败的函数是这样的-它是VB.NET(不要问...)

Public Async Function GenerateAccessToken(baseURL As String, authorization As String, clientID As String, clientSecret As String, resource As String) As Task(Of String)
        Dim responseString As String

        Try
            Dim client As HttpClient = HeadersForAccessTokenGenerate(baseURL, authorization)
            Dim body As String = ""

            Dim request As HttpRequestMessage = New HttpRequestMessage(HttpMethod.Post, client.BaseAddress)
            request.Content = New StringContent(body, Encoding.UTF8, "application/x-www-form-urlencoded")

            Dim postData As List(Of KeyValuePair(Of String, String)) = New List(Of KeyValuePair(Of String, String))()
            postData.Add(New KeyValuePair(Of String, String)("grant_type", "client_credentials"))
            postData.Add(New KeyValuePair(Of String, String)("client_id", clientID))
            postData.Add(New KeyValuePair(Of String, String)("client_secret", clientSecret))
            postData.Add(New KeyValuePair(Of String, String)("resource", resource))
            request.Content = New FormUrlEncodedContent(postData)

            Dim tokenResponse As HttpResponseMessage = client.PostAsync(baseURL, New FormUrlEncodedContent(postData)).Result

            responseString = Await tokenResponse.Content.ReadAsStringAsync()
        Catch ex As HttpRequestException
            Throw ex
        End Try

        'Return If(responseString.Contains("error"), responseString, token.AccessToken)
        Return (responseString)
    End Function


再次重申一下,这段代码在一台服务器上成功,但在另一台服务器上却失败了,而且在SoapUI中,它在两台服务器上都能工作。
我只能在我可以问客户问题的级别上,不能直接访问服务器,所以我必须接受客户的话,即服务器的配置是相同的。
我可以让他们检查什么?

drkbr07n

drkbr07n1#

我可能已经解决了这个问题。我无法与客户检查了一段时间,但把线

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls13

字符串
在我的开发系统上重现了他们的错误,所以我猜
System.Net.SecurityProtocolType.SystemDefault对于两个服务器实际上是不同的。
所有可能的值

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12


是一个使它再次在我的开发PC上工作。
我把它写下来,因为它可能会帮助别人。

相关问题