ssl - Paypal 快速结帐连接。客户端和服务器无法通信,因为它们不具备通用算法

标签 ssl encryption paypal paypal-sandbox tls1.2

我正在将 PayPal 结账功能集成到我们当前的电子商务网站。在我的本地计算机上,一切都按预期工作,但在暂存环境中,连接会引发以下错误:

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.ComponentModel.Win32Exception: The client and server cannot communicate, because they do not possess a common algorithm

正如 PayPal 文档所述,我们支持 SHA-256 并在服务器上安装了 G5 根证书 (https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1766&viewlocale=en_US&direct=en)。

服务器在 Windows Server 2008 R2 上运行,支持的密码为三重 DES 168、AES 128/128 和 AES 256/256。 如果 Tls12 不是硬编码的(见下文),它会抛出另一个错误:“无法创建 SSL/TLS 安全通道”。

如果有人可以提供帮助,我将不胜感激。 谢谢!

    public string SendRequest(string url, string postData) {

        var uri = new Uri(url);

        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
        var request = WebRequest.Create(uri);

        var encoding = new UTF8Encoding();
        var requestData = encoding.GetBytes(postData);

        request.ContentType = "application/x-www-form-urlencoded";
        request.Method = "POST";
        request.Timeout = (300*1000); //TODO: Move timeout to config
        request.ContentLength = requestData.Length;

        using (var stream = request.GetRequestStream()) {
            stream.Write(requestData, 0, requestData.Length);
        }

        var response = request.GetResponse();

        string result;

        using (var reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII)) {
            result = reader.ReadToEnd();
        }

        return result;
    }

最佳答案

最后我们弄清楚发生了什么。 在 Windows 2008R2 中,TLS 1.1 和 1.2 在客户端连接的注册表中默认被禁用。因此,虽然服务器本身可以接受传入请求的两种协议(protocol),但必须通过注册表启用传出客户端连接。

更改必须在协议(protocol) -> TLS 1.1(和 TLS 1.2) -> DisabledByDefault 下完成。

因此,只需更改这些值、重新启动,TLS 1.1 和 TLS 1.2 就应该可以工作了。

关于ssl - Paypal 快速结帐连接。客户端和服务器无法通信,因为它们不具备通用算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36541596/

相关文章:

java - 复制 OpenSSL 命令以在 Java 中签署文件

Java 客户端连接错误 : ChangeCipherSpec message sequence violation

java - 在Android应用程序中存储用户设置的最合适方法是什么

php - 这些密码有什么问题?

paypal - Paypal Sandbox 会更新企业帐户吗?

c# - C# 中的 PayPal 支付提供商

Magento 在 paypal 付款前下订单

sockets - Erlang:使用 sockets/gen_tcp 连接到 API

spring - 使用 SoapUI 测试自签名证书身份验证 Web 服务

java - 我可以只解密使用 Java 中的 AES/CBC 加密的文件的一部分吗?