0

我的 API 在使用 TLS 1.0 的服务上运行。我们使用SmartyStreets地理定位 API,它要求客户端使用 TLS 1.2

由于与某些旧应用程序的兼容性问题,我无法更新我们的 .NET 框架版本或 TLS 设置。

HttpClient我能够在我的GET 请求之前添加它:

ServicePointManager.Expect100Continue = false;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpResponseMessage response = await http.GetAsync(smartyStreetsUri);

这实际上让我可以在大约 40% 的时间里得到 SmartyStreets 的回复。所有其他请求我收到以下错误。我每次都使用相同的 GET URI:

发送请求时发生错误。异常:System.Net.WebException:基础连接已关闭:发送时发生意外错误。---> System.IO.IOException: Unable to read data from the transport connection: 一个现有的连接被远程主机强行关闭。---> System.Net.Sockets.SocketException: 现有连接被远程主机强行关闭

当我使用 TLS 1.0 时,我是否可以从使用 TLS 1.2 的服务器获得良好、一致的响应?

4

0 回答 0