【问题标题】:How to proxy secure web services (HTTPS SSL/TLS) using Mule's <pattern:web-service-proxy>如何使用 Mule 的 <pattern:web-service-proxy> 代理安全 Web 服务 (HTTPS SSL/TLS)
【发布时间】:2015-03-28 11:22:20
【问题描述】:

我们有本地运行的 CXF Web 服务,可通过 HTTPS TLS/SSL 访问。我们想使用 Mule 的 在外部公开这些服务。我们的问题是,可以将 配置为使用 HTTPS 吗?

我们已经使用 成功地通过 HTTP 代理了这些服务。但是,当我们将 web-service-proxy 的 inboundAddress 和 outboundAddress 属性(如下)从 HTTP URL 更改为 HTTPS URL 时,我们会收到错误消息:“所需的对象/属性“tls-key-store”为空”。

这行得通:

<pattern:web-service-proxy name="unsecure_ws_proxy"
    inboundAddress="http://localhost:80/services/service_common_name"
    outboundAddress="http://localhost:8080/app_name/proxied_service_name" 
/> 

这不起作用(产生“所需的对象/属性“tls-key-store”为空“):

<pattern:web-service-proxy name="secure_ws_proxy"
    inboundAddress="https://localhost:443/services/service_common_name"
    outboundAddress="https://localhost:8443/app_name/proxied_service_name" 
/>

我们已经定义了一个 并假设如果我们可以让 使用它,那么代理应该可以工作。

这个假设是否正确,如果正确,我们如何告诉 使用我们定义的 TLS_Context?如果我们的假设有误,那么在 Mule 中定义本质上是使用 HTTPS 协议的 CXF SOAP Web 服务的直通代理的最简单方法是什么?

编辑:

我们正在使用 Mule v.3.6.0。

为了完整起见,我们的 TLS_Context(我们还不知道如何将其与模式关联:web-service-proxy,如果这就是答案的话):

<tls:context name="TLS_Context" doc:name="TLS Context">
    <tls:trust-store path="${ssl.truststore.path}" password="${ssl.truststore.password}"/>
    <tls:key-store path="${ssl.keystore.path}" password="${ssl.keystore.password}" keyPassword="${ssl.keystore.password}"/>
</tls:context>

回答:

以下是完整的解决方案,基于 David 接受的回复。不需要 TLS_Context。谢谢大卫:

<?xml version="1.0" encoding="UTF-8"?>
<mule 
    xmlns="http://www.mulesoft.org/schema/mule/core" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:http="http://www.mulesoft.org/schema/mule/http" 
    xmlns:script="http://www.mulesoft.org/schema/mule/scripting"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:pattern="http://www.mulesoft.org/schema/mule/pattern"
    xmlns:https="http://www.mulesoft.org/schema/mule/https"
    xsi:schemaLocation="
       http://www.mulesoft.org/schema/mule/core 
       http://www.mulesoft.org/schema/mule/core/current/mule.xsd
       http://www.mulesoft.org/schema/mule/http 
       http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
       http://www.mulesoft.org/schema/mule/pattern 
       http://www.mulesoft.org/schema/mule/pattern/current/mule-pattern.xsd
       http://www.mulesoft.org/schema/mule/scripting 
       http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
       http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-current.xsd
       http://www.mulesoft.org/schema/mule/https 
       http://www.mulesoft.org/schema/mule/https/3.0/mule-https.xsd">

    <https:connector name="httpsConnector">
        <!-- Not currently needed 
        <https:tls-client 
            path="${ssl.client.keystore.path}" 
            storePassword="${ssl.client.keystore.password}"/>     
        -->   
        <https:tls-key-store 
            path="${ssl.server.keystore.path}" 
            keyPassword="${ssl.server.keystore.password}" 
            storePassword="${ssl.server.keystore.password}"/>
        <https:tls-server 
            path="${ssl.server.truststore.path}" 
            storePassword="${ssl.server.truststore.password}"/>
    </https:connector>

    <!-- Pattern-based configuration was introduced in Mule v.3.2 to decrease "the amount of 
        noise in its configuration files". Configuration patterns are, by design, not  as 
        powerful as Mule FLows or Services. They have instead been designed for ease of use. 
        (http://www.mulesoft.org/documentation-3.2/display/32X/Understanding+Configuration+Patterns+Using+Mule) -->

    <!-- MULE PATTERN PROXIES -->
    <!-- HTTP -->
    <pattern:web-service-proxy name="http_ws_proxy"
        inboundAddress="http://localhost:80/services/service_common_name"
        outboundAddress="http://localhost:8080/app_name/proxied_service_name" 
    />
    <!-- HTTPS -->
    <pattern:web-service-proxy name="https_ws_proxy"
        inboundAddress="https://localhost:443/services/service_common_name"
        outboundAddress="https://localhost:8443/app_name/proxied_service_name" 
    />

</mule>

【问题讨论】:

  • 请显示您的 HTTPS 连接器的完整配置。不要忘记屏蔽您的 JKS 密码。另请说明您使用的 Mule 版本。
  • 感谢您的回复。我们没有使用显式 HTTP 连接器。我们假设 Mule web-service-proxy Pattern 在幕后创建它。 Mule 配置文件中唯一的条目是我们在上面发布的内容。如前所述,“unsecure_ws_proxy”工作正常(没有明确的连接器)。为了简单起见,我们选择了一种模式而不是流。
  • Mule 会在您未明确配置它们时创建默认连接器。对于 HTTPS,默认连接器没有任何 JKS 配置(显然),因此您必须明确并配置它。
  • 啊哈!谢谢!我们会试一试。我假设连接器必须命名为“httpsConnector”,因为这就是 Mule 找到它的方式?
  • 不,它按类型找到它。名字可以是任何东西。

标签: web-services ssl https proxy mule


【解决方案1】:

您需要使用相关的 JKS 配置来配置 HTTPS 连接器。

例子:

<https:connector name="httpsConnector">
  <https:tls-key-store path="keystore.jks" keyPassword="<Your Password>"
         storePassword="<Your Password>"/>
</https:connector>

参考:http://www.mulesoft.org/documentation/display/current/HTTPS+Transport+Reference

【讨论】:

  • 感谢您的想法,大卫。两个问题:1)我们试图避免使用您引用的已弃用的 HTTP 连接器,以及 2)即使我们确实使用它,我们将如何配置 以使用它也不清楚.
  • 1) 那么你不能使用pattern:web-service-proxy,你需要使用一个流。 2) 如果您的配置中只有一个https:connector,则无需执行任何操作。
【解决方案2】:

当您的 https 连接器指向 http url 时,可能会发生这种情况。您可以更改 xml 中的 server/url 或禁用连接器中的 https 选项:

【讨论】:

    猜你喜欢
    • 2013-11-23
    • 1970-01-01
    • 2012-11-04
    • 2015-09-29
    • 2014-09-24
    • 2011-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多