WebRequest在Windows Server 2008 R2的TLS 1.2上失败



我知道有人问过类似的问题,但我的问题似乎是不同的,因为我已经尝试了许多我在网上找到的解决方案。我的问题如下:

我正在运行安装在IIS 7上的。net 4.5.1 MVC应用程序,它向仅支持TLS 1.2的外部服务器发出安全的出站请求。当我在Windows 7主机上运行应用程序时,一切都很好,但在Windows Server 2008 R2上,它充满了:

"请求被终止:无法创建SSL/TLS安全通道。"

一开始它在我的本地Windows 7上也失败了,直到我在WebRequest之前添加了这一行并工作:

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

但这并没有使它在服务器上工作。

我还试着添加:

ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(AllwaysGoodCertificate);
ServicePointManager.Expect100Continue = true;

但是没有做任何改变。

我还尝试在服务器上添加要接受的TLS 1.2协议,如下所示https://support.quovadisglobal.com/KB/a433/how-to-enable-tls-12-on-windows-server-2008-r2.aspx

重新启动机器,但仍无新信息。

提前感谢你,我对这个问题已经非常绝望了:S

我解决了这个问题

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

    System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

最新更新