RestSharp 怎么可能在测试环境下工作,而不是在我的本地机器上工作?

How is it possible that RestSharp is working on TEST-environment but not on my local machine?

我有一个非常奇怪的问题,现在我花了一天的时间。

错误异常。

System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.

at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)

at System.Net.HttpWebRequest.GetRequestStream()

at RestSharp.Http.WriteRequestBody(HttpWebRequest webRequest)

at RestSharp.Http.PostPutInternal(String method)

at RestSharp.RestClient.Execute(IRestRequest request, String httpMethod, Func`3 getResponse)

我的代码在测试环境中运行,但在我的本地环境中不起作用。该代码过去有效,没有任何改变。我在本地机器上用 SoapUi 复制了 REST 调用,它可以正常工作。我导入了 SSL 证书等。我的本地计算机正在运行 Windows 7 和测试环境 Windows Server 2008。两种环境都是 运行 .NET Framework 4.5。

我在网上搜索了一个解决方案,我找到了很多,例如 The request was aborted: Could not create SSL/TLS secure channel http://robertgreiner.com/2013/03/could-not-establish-trust-relationship-for-the-ssl-tls-secure-channel/

我尝试了可能的解决方案,但没有解决问题。有人知道解决办法吗?

非常感谢, 乔迪

您的测试环境与另一台服务器的握手过程中似乎出现了问题。

在调用服务器之前尝试此操作:

ServicePointManager.ServerCertificateValidationCallback =
                        (s, certificate, chain, sslPolicyErrors) => true;

PS:上面的行将禁用 SSL 验证。

SSL 证书的加密密钥太 low/bad,因此 Windows 在几次 Windows 更新后不再接受它。解决方案是用更高的加密密钥更新 SSL 证书。