I am currently using Mule Studio CE 1.3.2 as part of a dev environment. I was trying to set up a basic flow for testing purposes that contained an HTTPS inbound endpoint with the purpose of posting to it some data from a remote machine running a JSSE based client. The actual bit of the flow used is shown directly below:
`<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.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/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" doc:name="HTTP\HTTPS">
<https:tls-key-store path="Mule.jks" keyPassword="abc" storePassword="cdfg"/>
<https:tls-server path="Mule.jks" storePassword="cdfg"/>
<https:tls-protocol-handler property="com.sun.net.ssl.internal.www.protocol"/>
</https:connector>
<flow name="HttpsServerTestFlow1" doc:name="HttpsServerTestFlow1" processingStrategy="asynchronous">
<https:inbound-endpoint exchange-pattern="one-way" host="192.168.178.4" port="8080" path="test" mimeType="text/plain" connector-ref="HTTP_HTTPS" contentType="application/x-www-form-urlencoded" doc:name="HTTP"/>
<scripting:component doc:name="Python">
<scripting:script engine="jython">
<scripting:text><![CDATA[print "Mule message:"
print message
]]></scripting:text>
</scripting:script>
</scripting:component>
</flow>
</mule>`
Now when trying to connect from the java client whose code (using deprecated packages granted that, but it is meant only as a quick test) is:
`import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.Security;
import com.sun.net.ssl.HostnameVerifier;
import com.sun.net.ssl.HttpsURLConnection;
public class HTTPSClient {
private HttpsURLConnection urlConnection=null;
private static String host_address="192.168.178.47";
private static int ssl_port=8080;
public static void setHost_address(String host_address) {
HTTPSClient.host_address = host_address;
}
public static String getHost_address() {
return host_address;
}
public static void setSsl_port(int ssl_port) {
HTTPSClient.ssl_port = ssl_port;
}
public static int getSsl_port() {
return ssl_port;
}
static{
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
System.setProperty("javax.net.ssl.keyStore", "C:/Users/vangelis/client.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "xxxx");
System.setProperty("javax.net.ssl.trustStore", "C:/Users/vangelis/trust-client.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "xxxxc");
System.setProperty("https.protocols", "SSLv3");
}
public void sendData(String content){
try {
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier(){
@Override
public boolean verify(String hostname, String session) {
// TODO Auto-generated method stub
return (true);
}
});
URL url=new URL("https://"+getHost_address()+":"+getSsl_port()+"/test");
urlConnection=(HttpsURLConnection)url.openConnection();
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0");
urlConnection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
urlConnection.setDoOutput(true);
urlConnection.connect();
OutputStream out_stream = urlConnection.getOutputStream();
DataOutputStream out_stream_writer=new DataOutputStream(out_stream);
out_stream_writer.writeBytes(content);
out_stream_writer.close();
}
catch (MalformedURLException e) {
e.printStackTrace();
}
catch (java.net.SocketException e){
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
String data="data%3Dhello";
HTTPSClient secure_client= new HTTPSClient();
secure_client.sendData(data);
System.out.print("Done...");
}
}`
i always end up receiving in the mule end the following stack-trace:
**`ERROR 2015-03-05 14:56:09,525 [[httpsservertest].HTTP_HTTPS.receiver.02] org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in Exception Strategy: Connection reset
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:798)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:755)
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:311)
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)`**
Please bear in mind that if I use a second mule flow, with an https-outbound endpoint for the purposes of connecting to the flow with the inbound endpoint discussed above, then everything works correctly without any errors. It seems the problem lies with the java client code. Could someone please be so kind as to help me out a bit since what started as a quick and dirty integration test case is taking me ages to resolve. Thanks Vangelis