【问题标题】:How to connect to https server with Mule 2如何使用 Mule 2 连接到 https 服务器
【发布时间】:2023-03-27 03:08:01
【问题描述】:

我使用此命令将.pem 文件转换为.jks 一个(source):

keytool -importcert -alias debian -file cert.pem -keystore cert.jks -storepass passwd

这是 Mule 文件:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:http="http://www.mulesource.org/schema/mule/http/2.2"
    xmlns:https="http://www.mulesource.org/schema/mule/https/2.2"
    xsi:schemaLocation="
        http://www.mulesource.org/schema/mule/http/2.2 http://www.mulesource.org/schema/mule/http/2.2/mule-http.xsd
        http://www.mulesource.org/schema/mule/https/2.2 http://www.mulesource.org/schema/mule/https/2.2/mule-https.xsd
        http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd">

    <https:connector name="SslConnector" keepSendSocketOpen="true">
        <https:tls-client path="${mule.home}/cert.jks"
                          storePassword="passwd"/>
    </https:connector>

    <model>
        <service name="ConnectToHTTPS">
            <inbound>
                <http:inbound-endpoint host="localhost"
                                       port="9000"
                                       synchronous="true"/>
            </inbound>
            <outbound>
                <chaining-router>
                    <outbound-endpoint address="https://localhost"
                                       synchronous="true"/>
                </chaining-router>
            </outbound>
        </service>
    </model>
</mule>

现在,我明白了:

ERROR 2011-07-08 12:06:51,210 [main] org.mule.MuleServer: 
********************************************************************************
Message               : Initialisation Failure: Error creating bean with name 'SslConnector': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: The Key password cannot be null
Type                  : org.mule.api.lifecycle.InitialisationException
Code                  : MULE_ERROR-72085
JavaDoc               : http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/lifecycle/InitialisationException.html
Object                : org.mule.config.spring.SpringRegistry@160bf50
********************************************************************************
Exception stack is:
1. The Key password cannot be null (java.lang.IllegalArgumentException)
  org.mule.api.security.tls.TlsConfiguration:290 (null)
2. Error creating bean with name 'SslConnector': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: The Key password cannot be null (org.springframework.beans.factory.BeanCreationException)
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory:1338 (null)
3. Initialisation Failure: Error creating bean with name 'SslConnector': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: The Key password cannot be null (org.mule.api.lifecycle.InitialisationException)
  org.mule.registry.AbstractRegistry:76 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/lifecycle/InitialisationException.html)

旁注:这是对Is there a way to connect to https server by specifying only the url in Mule 2?的扩展

【问题讨论】:

    标签: https mule


    【解决方案1】:

    在尝试了您的配置后,我发现还需要一个 tls-key-store 元素。

    以下 HTTPS 配置允许“ConnectToHTTPS”成功命中 HTTPS 出站目标:

    <https:connector name="SslConnector" keepSendSocketOpen="true">
        <https:tls-client path="${mule.home}/cert.jks"
                          storePassword="passwd"/>
        <https:tls-key-store path="${mule.home}/cert.jks"
                             keyPassword="passwd"
                             storePassword="passwd" />
    </https:connector>
    

    【讨论】:

    • 我收到了unable to find valid certification path to requested target...。这是否意味着我必须有权访问私有证书?
    • 不,我尝试使用从通过 HTTPS 浏览的站点检索到的公共证书。
    • 您是否必须将其从.pem 格式转换?如果是这样,您使用了什么命令?
    • 我直接用keytool从网站上导入了我保存的证书,没有转换。我将其导出为 base64 编码的单一证书。
    猜你喜欢
    • 1970-01-01
    • 2014-04-06
    • 1970-01-01
    • 2016-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-19
    • 2020-06-16
    相关资源
    最近更新 更多