WebRequest在Windows Server 2008 R2的TLS 1.2上失败
问题描述:
我知道类似的问题已经被问到,但我的问题似乎有所不同,因为我已经尝试了许多我在网上找到的解决方案。我的问题如下。WebRequest在Windows Server 2008 R2的TLS 1.2上失败
我正在运行安装在IIS 7上的.net 4.5.1 MVC应用程序,该应用程序向仅支持TLS 1.2的外部服务器提供安全的出站请求。一切顺利,当我从Windows 7主机运行应用程序时,但在Windows Server 2008 R2上是fils:
“请求已中止:无法创建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
机器重新启动,但仍没有新的。
非常感谢你提前,我十分绝望的这个问题:■
答
我解决它改变这一行
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
此
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;