【问题标题】:WSO2 EI - 2 way SSL - handshake_failureWSO2 EI - 2 路 SSL - handshake_failure
【发布时间】:2022-03-11 10:54:23
【问题描述】:

我在设置双向 SSL 身份验证时遇到问题。 我需要从 wso2 企业集成商访问 HTTPS 端点。 服务提供商给了我一个 pfx 密钥库,其中包含我必须提供给服务器的证书和私钥。

我在我的 Windows 计算机上安装了这个 pfx 密钥库,并尝试从 Chrome 访问端点(端点在根上下文中有一个返回 hello 消息的 GET 服务)。访问此端点时,chrome 告诉我选择提供给服务器的证书...我选择好的证书并返回 hello 消息...很好,证书有效。

我也尝试使用 curl,提供密钥、cacert 和 cert(使用 openssl 从 pfx 文件中提取)。一切正常。

问题是当我尝试从 wso2 ei 服务访问此端点时。 我按照以下步骤使用 keytool 将我的 pfx 文件导入默认密钥库 (wso2carbon.jks):

  1. 在 jks 中导入 pfx

    keytool -importkeystore -srckeystore .pfx -srcstoretype pkcs12 -destkeystore wso2carbon.jks -deststoretype JKS -srcstorepass -deststorepass wso2carbon

  2. 导出 jks 公钥

    keytool -export -alias "" -keystore wso2carbon.jks -file publickey.pem -storepass wso2carbon

  3. 在默认client-trustore.jks中导入公钥

    keytool -import -alias "" -file publickey.pem -keystore client-truststore.jks -storepass wso2carbon

  4. 更新 wso2carbon 密钥库中别名的密码(必须与 jks pwd 相同)

    keytool -keypasswd -alias "" -new wso2carbon -keystore wso2carbon.jks -keypass -storepass wso2carbon

  5. 将根和中间服务器证书添加到信任库

    keytool -import -v -trustcacerts -alias root -file root.cer -keystore client-truststore.jks -storepass wso2carbon keytool -import -v -trustcacerts -alias intermed -file intermed.cer -keystore client-truststore.jks -storepass wso2carbon

重启 WSO2 EI 然后尝试访问端点(握手失败!!!)

我在错误痕迹下方激活了 -Djavax.net.debug=ssl:handshake。 似乎 WSO2 EI 找不到服务器要求的证书

...
*** CertificateRequest
Cert Types: RSA, DSS, ECDSA
Supported Signature Algorithms: SHA512withRSA, Unknown (hash:0x6, signature:0x2), SHA512withECDSA, SHA384withRSA, Unknown (hash:0x5, signature:0x2), SHA384withECDSA, SHA256withRSA, Unknown (hash:0x4, signature:0x2), SHA256withECDSA, SHA224withRSA, Unknown (hash:0x3, signature:0x2), SHA224withECDSA, SHA1withRSA, SHA1withDSA, SHA1withECDSA
Cert Authorities:
<CN=Autorite Bureau RTE, O=RTE, L=Pacy, ST=Eure, C=FR>
<CN=Autorite Racine RTE, O=RTE, L=Pacy, ST=Eure, C=FR>
<CN=Autorite Bureau Machine RTE, DC=bureau, DC=si, DC=interne>
*** ServerHelloDone
Warning: no suitable certificate found - continuing without client authentication
*** Certificate chain
<Empty>
***
*** ClientKeyExchange, RSA PreMasterSecret, TLSv1.2
PassThroughMessageProcessor-2, WRITE: TLSv1.2 Handshake, length = 320
SESSION KEYGEN:
PreMaster Secret:
... no IV derived for this protocol
PassThroughMessageProcessor-2, WRITE: TLSv1.2 Change Cipher Spec, length = 64
*** Finished
verify_data:  { 111, 185, 151, 74, 99, 156, 152, 185, 240, 222, 162, 116 }
***
PassThroughMessageProcessor-2, WRITE: TLSv1.2 Handshake, length = 80
PassThroughMessageProcessor-2, READ: TLSv1.2 Alert, length = 64
PassThroughMessageProcessor-2, RECV TLSv1.2 ALERT:  fatal, handshake_failure
%% Invalidated:  [Session-1, TLS_RSA_WITH_AES_256_CBC_SHA256]
%% Invalidated:  [Session-2, TLS_RSA_WITH_AES_256_CBC_SHA256]
PassThroughMessageProcessor-2, called closeSocket()
PassThroughMessageProcessor-2, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
PassThroughMessageProcessor-2, called close()
PassThroughMessageProcessor-2, called closeInternal(true)

我尝试使用 SOAP UI,引用之前创建的密钥库,GET 调用返回 hello 消息(握手成功)。

我还尝试了使用该密钥库的 sn-p java 类,并且 ssl 握手过程正常。

System.setProperty("javax.net.ssl.keyStore", keystorePath);
        System.setProperty("javax.net.ssl.keyStorePassword", CERT_PASSWORD);
        System.setProperty("javax.net.ssl.keyStoreType", "JKS");
        URL myUrl;
        try {
            myUrl = new URL(endpoint);
            HttpsURLConnection conn = (HttpsURLConnection) myUrl.openConnection();
            InputStream is = conn.getInputStream();
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);

            String inputLine;

            while ((inputLine = br.readLine()) != null) {
                System.out.println(inputLine);
            }

Cert Authorities:
<CN=Autorite Bureau RTE, O=RTE, L=Pacy, ST=Eure, C=FR>
<CN=Autorite Racine RTE, O=RTE, L=Pacy, ST=Eure, C=FR>
<CN=Autorite Bureau Machine RTE, DC=bureau, DC=si, DC=interne>
*** ServerHelloDone
matching alias: alias-cert

感谢您的帮助。 谢谢。

亲切的问候, 鲁迪

【问题讨论】:

  • 您好,是的,我做到了,只是我确实注意到创建了一个新的 jks。我更喜欢将其导入 wso2carbon 默认之一,以避免所有 xml 配置文件进行更新。
  • 您可以尝试在 client-truststore.jks 文件中导入这些证书,因为它们是 wso2 产品不使用的证书,所以我觉得它是第 3 方证书,因此它正在客户端中查找-truststore.jks.
  • 你好,我尝试了很多东西,包括你提到的,但没有成功......我还更新了 wso2ei 以仅使用 wso2carbon.jks 作为信任和密钥库来简化我的测试......顺便说一句,我写了一个小 java 类(独立,不使用 wso2 产品),并且 ssl 过程顺利,客户端找到了有关服务器证书请求的适当证书......看起来 wso2 配置中有问题,但找不到位置跨度>

标签: ssl wso2 esb handshake ei


【解决方案1】:

要解决此问题,请查看您在axis2.xml 文件中的配置,观察名称为“https”的元素transportSender,然后插入customSSLProfiles 的配置。

操作方法在此文档中:

https://docs.wso2.com/display/EI660/HTTPS-NIO+Transport+

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多