c# - 调用 SSL 支付网关时出错 : "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel"

标签 c# asp.net iis ssl braintree

迈出实现支付网关的第一步。

在 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/

相关文章:

c# - 在一行中将字符串转换为 DateTime 可为空的变量

c# - 如何用C#连接mysql(简单程序)

asp.net - GridView 编辑按钮需要单击 2 次

javascript - 无法打开ajaxToolkit :ModalPopupExtender with JavaScript

asp.net - session Cookie(与身份验证相关)不包含 "HTTPOnly"属性

iis - ColdFusion 9 在 Tomcat 7 上的 ODBC 套接字数据源问题

c# - .Net 中的内置字符大小写功能

c# - 是否可以在 MS Entity Framework 中查询新添加的对象

powershell - 在 IIS Powershell 中添加 GET HEAD 和 POST 动词

asp.net - 强制 SSL 连接