c# - 客户端和服务器无法通信,因为它们不具备通用算法 - ASP.NET C# IIS TLS 1.0/1.1/1.2 - Win32Exception

标签 c# asp.net ssl iis-7.5 poodle-attack

我对 C# PayTrace 网关有疑问。下面的代码在昨天之前工作正常,当时我相信他们由于 Poodle Exploit 而关闭了 SSL3。运行下面的代码时,我们收到以下消息。远程服务器已强行关闭连接。在对该问题进行一些研究后,我们确定由于我们的 IIS Server 7.5 配置为仍使用 SSL3,因此 C# 默认为 SSL3,PayTrace 将强行关闭连接。然后我们从服务器中删除了 SSL3。然后导致以下错误:

客户端和服务器无法通信,因为它们不具备通用算法。

我的猜测是,既然 SSL 3 已被删除,我们还需要在服务器上安装额外的 SSL 算法。我们的 IT 人员声称 TLS 1.1 和 TLS 1.2 正在运行,并且 ASP.NET 现在应该默认使用这些。但我觉得我们还必须在服务器上安装其他东西,我不了解 SSL 算法,所以我不知道从哪里开始。

var postUrl = new StringBuilder();

//Initialize url with configuration and parameter values...
postUrl.AppendFormat("UN~{0}|", this.MerchantLoginID);
postUrl.AppendFormat("PSWD~{0}|", this.MerchantTransactionKey);
postUrl.Append("TERMS~Y|METHOD~ProcessTranx|TRANXTYPE~Sale|"); 
postUrl.AppendFormat("CC~{0}|", cardNumber);
postUrl.AppendFormat("EXPMNTH~{0}|", expirationMonth.PadLeft(2, '0'));
postUrl.AppendFormat("EXPYR~{0}|", expirationYear);
postUrl.AppendFormat("AMOUNT~{0}|", transactionAmount);
postUrl.AppendFormat("BADDRESS~{0}|", this.AddressLine1);
postUrl.AppendFormat("BADDRESS2~{0}|", this.AddressLine2);
postUrl.AppendFormat("BCITY~{0}|", this.City);
postUrl.AppendFormat("BSTATE~{0}|", this.State);
postUrl.AppendFormat("BZIP~{0}|", this.Zip);
postUrl.AppendFormat("SADDRESS~{0}|", this.AddressLine1);
postUrl.AppendFormat("SADDRESS2~{0}|", this.AddressLine2);
postUrl.AppendFormat("SCITY~{0}|", this.City);
postUrl.AppendFormat("SSTATE~{0}|", this.State);
postUrl.AppendFormat("SZIP~{0}|", this.Zip);
if (!String.IsNullOrEmpty(this.Country))
{
    postUrl.AppendFormat("BCOUNTRY~{0}|", this.Country);
}
if (!String.IsNullOrEmpty(this.Description))
{
    postUrl.AppendFormat("DESCRIPTION~{0}|", this.Description);
}
if (!String.IsNullOrEmpty(this.InvoiceNumber))
{
    postUrl.AppendFormat("INVOICE~{0}|", this.InvoiceNumber);
}
if (this.IsTestMode)
{
    postUrl.AppendFormat("TEST~Y|");
}

//postUrl.Append();

WebClient wClient = new WebClient();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
String sRequest = "PARMLIST=" + Url.Encode(postUrl.ToString());
wClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
string sResponse = "";
sResponse = wClient.UploadString(PayTraceUrl, sRequest);

此外,仅供引用,当我们连接到 First Data E4 网关时也会发生此问题,因此这不仅仅是 PayTrace 问题。我的猜测是,随着越来越多的网关关闭对 SSL3 的访问,我们将继续遇到其他网关的问题,直到可以在服务器上解决这个问题。另外,我确实在网上找到了一些建议,有些人建议在发出出站请求之前放置以下代码:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

不幸的是,这也不起作用,同样的错误。这就是为什么我认为需要在 IIS7.5 服务器上安装一些额外的东西。我只是不确定是什么。

最佳答案

现在还有其他几篇关于此的帖子,它们都指向启用 TLS 1.2。任何不足都是不安全的。

您可以使用补丁在 .NET 3.5 中执行此操作。
您可以在 .NET 4.0 和 4.5 中使用一行代码完成此操作

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // .NET 4.5
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; // .NET 4.0

在 .NET 4.6 中,它自动使用 TLS 1.2。

详情请看这里: .NET support for TLS .

关于c# - 客户端和服务器无法通信,因为它们不具备通用算法 - ASP.NET C# IIS TLS 1.0/1.1/1.2 - Win32Exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26742054/

相关文章:

c# - Rhino - 模拟类而不是覆盖虚拟方法

javascript - 启用/禁用 asp :dropdownlist using jquery not working

macos - 在没有 Mac 开发者程序的情况下签署 Mac 应用程序

c# - 我可以将 WebSockets 用于桌面应用程序吗?

c# - 为什么我不能在程序的两个实例之间拖动一个点?

asp.net - 如何获取服务器端var值?

ssl - 证书错误DLG_FLAGS_SEC_CERT_CN_INVALID

mongodb - 确保云中 MongoDB 传输的安全

c# - 对象到对象映射实用程序

asp.net - 通过 ASP.NET 格式化 Excel 单元格