迈出实现支付网关的第一步。
在 win 8.1 下从 IIS 8.5 中托管的我的 ASP.net 代码调用 Braintree 和 Beantream 支付网关导致:
"The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel"
请注意,从位于同一个盒子上的我的中间层调用相同的服务工作正常,因此证书安装正确。
这是通过他们的 SDK 调用 Braintree 服务的示例代码:
[System.Web.Services.WebMethod]
public static CheckinDetailResponse GetViewData()
{
CheckinDetailResponse response = new CheckinDetailResponse()
{
ClientToken = string.Empty,
IsSuccessful = false,
ErrorMessage = string.Empty
};
try
{
response.ClientToken = GetPaymentToken();
response.IsSuccessful = true;
}
catch (BaseDataServicesException ex)
{
response.ErrorMessage = ex.GetLocalizedMessage(Resources.WebCommon.ResourceManager);
}
return response;
}
private static string GetPaymentToken()
{
var gateway = new BraintreeGateway
{
Environment = Braintree.Environment.SANDBOX,
MerchantId = "999",
PublicKey = "999",
PrivateKey = "999"
};
var clientToken = gateway.ClientToken.generate(null);
return JsonDcSerialization.ToJsonString(clientToken); ;
}
是否需要在 IIS 中进行一些特殊设置才能从 Web 应用程序调用 SSL 服务?
谢谢!
最佳答案
检查机器上是否安装了 SSL 证书,是否将它们传递给代码,以及您使用的机器是否配置为接受证书颁发者作为受信任的。
关于c# - 调用 SSL 支付网关时出错 : "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30671961/