https connector working example wanted

Hi all.

I have tried hard to set up a https inbound connection, but I keep getting the same error.

I have followed the descriptions in "Setting up a HTTPS Server" from http://www.mulesoft.org/documentation....

This is my mule-test-config.xml:

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

<description>End 2 End Test</description>

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

<flow name="test.donothing">
<composite-source>
<https:inbound-endpoint address="https://localhost:7654/donothing" exchange-pattern="request-response"/>
<http:inbound-endpoint address="http://localhost:8765/donothing" exchange-pattern="request-response"/>
<vm:inbound-endpoint address="vm://test" exchange-pattern="request-response"/>
</composite-source>
<object-to-string-transformer/>
<test:component logMessageDetails="true" enableNotifications="true"/>
</flow>
</mule>


This is my test:

public class MuleFunctionalTest extends FunctionalTestCase {

@Override
protected String getConfigResources() {
return "mule-test-config.xml";
}

@Test
public void testComponentReturnsResultOverHttps() throws Exception {
MuleClient client = new MuleClient(muleContext);
String payload = "foo";
Map<String, Object> properties = null;
MuleMessage result = client.send("https://localhost:7654/donothing", payload, properties);
assertThat("Result", result.getPayloadAsString(), is(equalTo("foo")));
}


This is the error I keep getting:

ERROR 2012-04-20 15:23:03,215 [httpsConnector.receiver.02] org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in Exception Strategy: Received fatal alert: certificate_unknown
javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1806)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:986)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1170)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:785)
at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:50)
at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
at org.mule.transport.http.HttpServerConnection.readLine(HttpServerConnection.java:219)
at org.mule.transport.http.HttpServerConnection.readRequest(HttpServerConnection.java:185)
at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:155)
at org.mule.work.WorkerContext.run(WorkerContext.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)


Any hints are more than welcome!
2 people have
this question
+1
Reply
  • Humm, it seems I am getting into a habit of answering my own questions...

    To make the test pass, I started from the https connector reference example of how to create a self-signed certificate:
    keytool -genkey -alias mule -keyalg RSA -keystore keystore.jks

    I then extracted the certificate and created a truststore containing that certificate:
    keytool -export -alias mule -keystore keystore.jks -rfc -file mule.cer
    keytool -import -alias mulecert -file mule.cer -keystore truststore.jks


    I dropped the truststore into src/test/tesources and changed the test to the following:
    @Test
    public void testComponentReturnsResultOverHttps() throws Exception {
    MuleClient client = new MuleClient(muleContext);
    String payload = "foo";
    Map<String, Object> properties = null;
    final String trustStorePath = ClassLoader.getSystemResource("truststore.jks").getFile();
    System.setProperty("javax.net.ssl.trustStore", trustStorePath);
    System.setProperty("javax.net.ssl.trustStorePassword", "test");
    MuleMessage result = client.send("https://localhost:7654/donothing", payload, properties);
    assertThat("Result", result.getPayloadAsString(), is(equalTo("foo")));
    }


    Got a lot of help by reading the JSSE Reference guide from here:
    http://docs.oracle.com/javase/7/docs/...
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • This reply was removed on 2012-04-23.
    see the change log
  • Is there a possibility to catch these SSL exception and send and SSL Failure messages to client?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly