在Mule ESB中创建HTTPS服务

时间:2013-04-23 17:03:03

标签: https mule

我正在尝试创建一个使用HTTPS入站端点的流程。

到目前为止,我设法做到以下几点:

  • 使用以下命令通过终端创建密钥库文件:

    keytool -genkey -alias mule -keyalg RSA -keystore keystore.jks

  • 将keystore.jks放在我的mule app src / main / resources目录中

  • 使用以下设置创建了一个全局HTTPS连接器:

enter image description here

  • 在我的HTTP入站端点中选中“启用HTTPS”复选框,并选择我的新全局HTTPS连接器作为连接器引用。

当我访问所述端点时,我的问题就出现了     https://localhost:8082/getProducts

浏览器会抛出此消息

SSL connection error
Unable to make a secure connection to the server. This may be a problem with the server,     or it may be requiring a client authentication certificate that you don't have.
Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.

在我的骡子日志中,我有以下内容:

ERROR 2013-04-23 12:08:55,451 [[integrador-catalogogit].connector.http.mule.default.receiver.02] org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in Exception Strategy: Http Request line is malformed: "�?��?Qv??e]?.�t#?G??*?p?V*????stS��H?"
org.apache.commons.httpclient.ProtocolException: Http Request line is malformed: "�?��?Qv??e]?.�t#?G??*?p?V*????stS��H?"
at org.mule.transport.http.RequestLine.parseLine(RequestLine.java:52)
at org.mule.transport.http.HttpServerConnection.readRequest(HttpServerConnection.java:190)
at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:155)
at org.mule.work.WorkerContext.run(WorkerContext.java:311)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)
ERROR 2013-04-23 12:08:55,467 [[integrador-catalogogit].connector.http.mule.default.receiver.03] org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in Exception Strategy: Http Request line is malformed: "�?��?Qv???P?*?~c?q?6?]??W?[??��H?"
org.apache.commons.httpclient.ProtocolException: Http Request line is malformed: "�?��?Qv???P?*?~c?q?6?]??W?[??��H?"
at org.mule.transport.http.RequestLine.parseLine(RequestLine.java:52)
at org.mule.transport.http.HttpServerConnection.readRequest(HttpServerConnection.java:190)
at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:155)
at org.mule.work.WorkerContext.run(WorkerContext.java:311)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)
ERROR 2013-04-23 12:08:55,469 [[integrador-catalogogit].connector.http.mule.default.receiver.03] org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in Exception Strategy: Http Request line is malformed: "��U��Q�Qv?cN????;]<???-???^S???G[?��*�?�?�?�9�8�?�5�E�D�f�3�2�?�A���/��??�"
org.apache.commons.httpclient.ProtocolException: Http Request line is malformed: "��U��Q�Qv?cN????;]<???-???^S???G[?��*�?�?�?�9�8�?�5�E�D�f�3�2�?�A���/��??�"
at org.mule.transport.http.RequestLine.parseLine(RequestLine.java:52)
at org.mule.transport.http.HttpServerConnection.readRequest(HttpServerConnection.java:190)
at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:155)
at org.mule.work.WorkerContext.run(WorkerContext.java:311)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)

可能我在服务器端或mule端缺少配置步骤。

我真的很感激帮助。

修改

我的XML最终看起来像this

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.3.1" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.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/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
    <https:connector name="HTTP_HTTPS" cookieSpec="netscape" validateConnections="true" sendBufferSize="0" receiveBufferSize="0" receiveBacklog="0" clientSoTimeout="10000" serverSoTimeout="10000" socketSoLinger="0" proxyHostname="localhost" proxyPort="80" doc:name="HTTP\HTTPS">
        <https:tls-client path="keystore.jks" storePassword="1234"/>
        <https:tls-key-store path="keystore.jks" keyPassword="1234" storePassword="1234"/>
        <https:tls-server path="keystore.jks" storePassword="1234"/>
    </https:connector>
    <flow name="getProducts" doc:name="getProducts">
        <https:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="getProducts" doc:name="HTTP" connector-ref="HTTP_HTTPS"/>
        <json:json-to-object-transformer returnClass="Codefuel.parameters.RequestParameters" doc:name="JSON to Object"/>
        <component class="Codefuel.product.mulesoft.GetProductByParameters" doc:name="GetProductByParameters"/>
        <json:object-to-json-transformer doc:name="Object to JSON"/>
    </flow>
</mule>

2 个答案:

答案 0 :(得分:1)

我已经在您的问题中创建了一个带有命令的密钥库(密码为1234561234太短)并部署了您的配置(除了我删除了json:json-to-object-transformer和{{ 1}},因为我在Mule 3.4上没有这个类,而且效果很好。

我可以component并得到回复。因此,必须有一些你没有表现出来的东西会导致麻烦。

答案 1 :(得分:0)

我有这个例外: org.mule.exception.DefaultSystemExceptionStrategy:异常策略中的捕获异常:Http Request行格式错误:(疯狂的charset caracters)

我滚动直到我意识到我的http服务位于https服务的同一端口。更改端口并重试,它适用于我。