Mule SQS Connector throwing javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated - java

I have a problem sending and receiving messages using Mule SQS Connector. Mule starts ok but throws javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated exception when i try to send or receive messages.
I am using keystores for other https outbounds.
Here is my flow
<sqs:config name="Amazon_SQS" accessKey="${AMAZON.ACCESS.KEY}"
secretKey="${AMAZON.SECRET.KEY}" queueName="${AMAZON.QUEUE.NAME}"
doc:name="Amazon SQS">
</sqs:config>
<flow name="TestFlow" doc:name="TestFlow">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8081" path="post" doc:name="HTTP" />
<set-payload
value="#['hello']"
doc:name="Set Payload" />
<json:object-to-json-transformer
doc:name="Object to JSON" />
<sqs:send-message config-ref="Amazon_SQS" doc:name="Amazon SQS"/>
</flow>

Per this question Getting "peer not authenticated" exception on Amazon SQS I'm wondering what JRE are you using? Do you have a recent Oracle JRE?
Per this blog post http://myjavacodeworld.blogspot.ca/2012/12/javaxnetsslsslpeerunverifiedexception.html, it seems you could use -Dcom.amazonaws.sdk.disableCertChecking=true to bypass the issue.

Related

Cxf Endpoint getting up with start of camel context. How I can avoid this?

I am using CXF endpoint for soap web service. And when my camel context starts it check whether web service is running or not. I want to change it like when my route call the CXF endpoint at that time it should check whether my service is running or not?
Any suggestions for fulfilling my requirement?
CXF Endpoint:
<cxf:cxfEndpoint id="accountBalanceServiceEndpoint"
address="{{wsdlUrlTest}}"
wsdlURL="{{wsdlUrlTest}}?wsdl"
serviceName="s:AccountBalanceService"
endpointName="s:AccountBalancePort"
xmlns:s="http://soap.test.pqr.abc.com/">
<cxf:properties>
<entry key="dataFormat" value="MESSAGE"/>
</cxf:properties>
</cxf:cxfEndpoint>
Route:
<route id="SoapService" startupOrder="40">
<from uri="direct:SoapService" />
<setHeader headerName="operationNamespace">
<constant>http://soap.test.pqr.abc.com/</constant>
</setHeader>
<setHeader headerName="operationName">
<constant>getContacts</constant>
</setHeader>
<setBody>
<simple>
<![CDATA[
<soapenv:Envelope
xmlns:q0="http://soap.test.pqr.abc.com/"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>
<soapenv:Body>
<q0:getContacts>
<arg0>
<custId>12345</custId>
</arg0>
</q0:getContacts>
</soapenv:Body>
</soapenv:Envelope>
]]>
</simple>
</setBody>
<to uri="cxf:bean:accountBalanceServiceEndpoint?defaultOperationName=getContacts" />
</route>
CXF doesn't check the availability of the service you are invoking when the route is starting up. CXF will only establish Http(s)Connection when the request is made. I am suspecting you are running into issues with discovering WSDL from the endpoint of service you are invoking in which case, it may establish a connection to download the WSDL and schemas when CXFEndpoint is instantiated.
Downloading the WSDL and schemas first and load it from file offline instead of using serviceUrl?WSDL may help you.

Mule MSMQ flow gives connection refused error in Mule Studio

I'm trying to run the sample example from Mule blog for MSMQ.
When I setup MSMQ as global component "Test connection" says Successful, that means MSMQ is setup. Well and good till now..
Now using the following flow to test sending a message into queue:
<msmq:config name="MSMQ" serviceAddress="machinename/localhost:9000" accessToken="XZodtPym+v6NeZs+Sr4+GK9EGdA=" rootQueueName=".\private$\msmq-demo" doc:name="MSMQ" >
<msmq:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW"/>
</msmq:config>
<flow name="testingFlow1" doc:name="testingFlow1">
<http:inbound-endpoint exchange-pattern="one-way" host="localhost" port="8091" doc:name="HTTP"/>
<set-payload value="#[header:INBOUND:http.relative.path]" doc:name="Set Payload"/>
<logger message=" Sending message: #[payload]" level="INFO" doc:name="Logger"/>
<msmq:send config-ref="MSMQ" doc:name="MSMQ"/>
</flow>
When the flow hits MSMQ in console I see this error:
INFO 2014-08-07 18:00:41,299 [[testing].testingFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor: Sending message: test
ERROR 2014-08-07 18:00:42,888 [[testing].testingFlow1.stage1.02] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: Work Descriptor. Root Exception was: Connection refused: connect. Type: class java.net.ConnectException
ERROR 2014-08-07 18:00:42,894 [[testing].testingFlow1.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Failed to invoke send. Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Connection refused: connect (java.net.ConnectException)
java.net.DualStackPlainSocketImpl:-2 (null)
2. java.net.ConnectException: Connection refused: connect (com.sun.jersey.api.client.ClientHandlerException)
com.sun.jersey.client.urlconnection.URLConnectionClientHandler:148 (null)
3. Failed to invoke send. Message payload is of type: String (org.mule.api.MessagingException)
org.mule.modules.msmq.processors.SendMessageProcessor:198 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
Any help or directions is welcome!
msmq-config picture for clarity:
Test connection succeeds
The proof of the pudding is Mule not Studio: if Mule can't connect then Studio most probably can't either, but fails to report the issue.
So you need to fix the msmq:config element until it works.
At first glance, this serviceAddress="machinename/localhost:9000" looks highly suspicious. You should either use the actual machine name and port or localhost and port if running collocated with MSMQ.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:msmq="http://www.mulesoft.org/schema/mule/msmq" 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="EE-3.6.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="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
http://www.mulesoft.org/schema/mule/msmq http://www.mulesoft.org/schema/mule/msmq/current/mule-msmq.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<msmq:config name="MSMQ" serviceAddress="x.x.x.:9333" accessToken="wRuoma0PhX4ZHA1vQosdefff=" rootQueueName=".\private$\msmqdemo" ignoreSSLWarnings="true" doc:name="MSMQ"/>
<flow name="msmqreceiveFlow">
<set-payload value="Hello" doc:name="Set Payload"/>
<msmq:send config-ref="MSMQ__MSMQ_Connection" queueName="msmqdemo" doc:name="MSMQ"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
Try this example I think service address is wrong.This example for sending message to MSMQ queue

Mule malformed endpoint error

I am new to Mule and trying to post a GET request using the HTTP endpoint, but I am receiving the following error
"Template Endpoint "http://api.mymemory.translated.net:80/get?q=#[message.inboundProperties.get('http.relative.path')]&langpair=EN|IT" resolved into a Malformed endpoint "http://api.mymemory.translated.net:80/get?q=hello&langpair=EN|IT". Failed to route event via endpoint: org.mule.endpoint.DynamicOutboundEndpoint"
I have tried the following configurations:
get?q=hello&langpair=EN%7CIT [WORKS]
get?q=#[message.inboundProperties.get('http.relative.path')]&langpair=EN%7CIT [DOESN'T WORK]
get?q=#[message.inboundProperties.get('http.relative.path')]&langpair=EN|IT
[DOESN'T WORK]
The stack trace seems to indicate that there is a problem with the "|" character.
My flow is as follows:
<flow name="my_first_projectFlow1" doc:name="my_first_projectFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<http:outbound-endpoint exchange-pattern="request-response" host="api.mymemory.translated.net" port="80" path="get?q=#[message.inboundProperties.get('http.relative.path')]&langpair=EN%7CIT" method="GET" doc:name="HTTP"/>
<echo-component doc:name="Echo"/>
</flow>
Try replacing the pipe ("|") char with MEL expression #[java.net.URLEncoder.encode('|', 'UTF-8')].

camel cxf client soap fault handling

I'm using camel and cxf component to get some data from web-service. In some case web-service returns standard soap:fault.
I have the next steps:
<camel:route id="someId">
<camel:onException useOriginalMessage="false">
<camel:exception>java.lang.Exception</camel:exception>
<camel:handled>
<camel:constant>false</camel:constant>
</camel:handled>
<camel:process ref="defaultNaoIntegrationErrorHandler" />
<camel:to uri="ref:naointegration.checkAvailability.jms.error.queue" />
</camel:onException>
<camel:from uri="direct:naoCheckAvailabilityOut" />
<camel:marshal ref="soapjaxbSAP" />
<camel:to id="naoCheckAvailabilityEndpoint" uri="cxf:bean:naoCheckAvailabilityEndpoint" />
<camel:unmarshal ref="soapjaxbSAP" />
</camel:route>
where naoCheckAvailabilityEndpoint is:
<cxf:cxfEndpoint id="naoCheckAvailabilityEndpoint"
address="${naointegration.I011.CheckAvailability.soap.address}"
endpointName="s:checkAvailabilityEndpoint" serviceName="s:SOAPService"
xmlns:s="http://www.example.com/test">
<cxf:properties>
<entry key="dataFormat" value="MESSAGE" />
<entry key="setDefaultBus" value="true" />
</cxf:properties>
<cxf:outInterceptors>
<ref bean="logOutbound" />
</cxf:outInterceptors>
<cxf:inFaultInterceptors>
<ref bean="logOutbound" />
</cxf:inFaultInterceptors>
</cxf:cxfEndpoint>
If I'm getting normal soap message everything is ok. And when I'm getting soap foalt/http 500 I have just string message which contains soap message (xml) with soap fault.
Reading cxf and camel mail lists on like problems I understood cxf endpoint should throw exception if there soap foalt, exception of type org.apache.cxf.binding.soap.SoapFault, but I can not get it.
The goal is onException clause do handling of soap fault exception.
Any suggestions?
You are using the MESSAGE data format, which means the camel-cxf endpoint just pass the stream from the transport, it will not read the under layer message, so the camel-cxf endpoint cannot tell which message is normal soap message or soap fault message.
If you want to let the camel route deal with the soap fault, you need to use the PAYLOAD or POJO data format.

Why do I get a bad_certificate error when using spring and CXF

I am using CXF generated code to connect to a remote web service over SSL and through a corporate proxy. The code works fine when the connection is established through the Java API and all SSL settings are set as system properties as follows.
System.setProperties("https.proxyHost", "myproxy.com");
System.setProperties("https.proxyPort", "8001");
System.setProperties("javax.net.ssl.keyStoreType", "pkcs12");
System.setProperties("javax.net.ssl.keyStore", "C:/keystore.p12");
System.setProperties("javax.net.ssl.keyStorePassword", "keypassword");
System.setProperties("javax.net.ssl.trustStore", "C:/cacerts");
System.setProperties("javax.net.ssl.trustStorePassword", "capassword");
MyWebService_Service ss = new MyWebService_Service(wsdlUrl, SERVICE_NAME);
MyWebService service = ss.getMyWebServicePort();
Using this code I can now call the service methods and everything works as expected. My problems occur when I try to set up the same configuration with Spring, which is our preferred approach since we are already using Spring extensively.
My Spring config:
<!-- relevant snippet from spring context -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
<jaxws:client id="webservice" serviceName="myns:MyWebService" endpointName="myns:MyWebServicePort"
address="https://bigserver.com:5012/blah/TheWebService"
serviceClass="com.mycomp.MyWebService" />
<http:conduit name="{myns}MyWebServicePort.http-conduit">
<http:tlsClientParamenters disableCNCheck="true" secureSocketProtocol="TLS">
<sec:trustManagers>
<sec:keyStore type="JKS" password="capassword" file="c:/cacerts" />
</sec:trustmanagers>
<sec:keyManagers>
<sec:keyStore type="pkcs12" password="keypassword" file="c:/keystore.p12" />
</sec:keyManagers>
</http:tlsClientParamenters>
<http:client ProxyServer="myproxy.com" ProxyServerPort="8001" />
</http:conduit>
In both cases, the web service client is deployed within a web application. In the second case, access to the web service results in a
javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
Edit: I am using CXF version 2.2.
Have you tried adding the next property to your client parameters?
**useHttpsURLConnectionDefaultHostnameVerifier="false"**
Looks like this:

Categories