我对 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 服务器上安装一些额外的东西。我只是不确定是什么。