Hi,
I'm using the camel-http component to communicate with an SSL web service
and I'm receiving the following exception:
java.security.KeyStoreException: No private keys found in keystore!
at
org.apache.commons.ssl.KeyStoreBuilder.validate(KeyStoreBuilder.java:269)
at
org.apache.commons.ssl.KeyStoreBuilder.build(KeyStoreBuilder.java:129)
at org.apache.commons.ssl.KeyMaterial.<init>(KeyMaterial.java:179)
at org.apache.commons.ssl.KeyMaterial.<init>(KeyMaterial.java:170)
at org.apache.commons.ssl.KeyMaterial.<init>(KeyMaterial.java:160)
at org.apache.commons.ssl.KeyMaterial.<init>(KeyMaterial.java:64)
at org.apache.commons.ssl.KeyMaterial.<init>(KeyMaterial.java:139)
at
org.apache.commons.httpclient.contrib.ssl.AuthSSLProtocolSocketFactory.<init>(AuthSSLProtocolSocketFactory.java:191)
at
tutorial.HttpClientConfigurer.configureHttpClient(HttpClientConfigurer.java:22)
at
org.apache.camel.component.http.CompositeHttpConfigurer.configureHttpClient(CompositeHttpConfigurer.java:40)
at
org.apache.camel.component.http.HttpEndpoint.createHttpClient(HttpEndpoint.java:105)
at
org.apache.camel.component.http.HttpProducer.<init>(HttpProducer.java:56)
at
org.apache.camel.component.http.HttpEndpoint.createProducer(HttpEndpoint.java:75)
at
org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:196)
at
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:133)
at
org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94)
at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:93)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
at
org.apache.camel.processor.TryProcessor.process(TryProcessor.java:63)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:93)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)
at
org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:66)
at
org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
at
org.apache.camel.component.mina.MinaConsumer$ReceiveHandler.messageReceived(MinaConsumer.java:110)
at
org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived(AbstractIoFilterChain.java:570)
at
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
at
org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
at
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
at
org.apache.mina.filter.LoggingFilter.messageReceived(LoggingFilter.java:89)
at
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
at
org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
at
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
at
org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.java:220)
at
org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(ExecutorFilter.java:264)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
at java.lang.Thread.run(Thread.java:595)
I have implemented the interface HttpClientConfigurer and here it is:
package tutorial;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.GeneralSecurityException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
import org.apache.commons.httpclient.contrib.ssl.*;
import org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory;
public class HttpClientConfigurer implements
org.apache.camel.component.http.HttpClientConfigurer {
public void configureHttpClient(HttpClient client) {
// register the customer SSLFactory
Protocol authhttps;
try {
authhttps = new Protocol("https",
(ProtocolSocketFactory) new
AuthSSLProtocolSocketFactory(
new
URL("file:./src/main/resources/ClientKey.jks"), "pwd",
new
URL("file:./src/main/resources/ClientTrust.jks"),
"pwd"), 443);
Protocol.registerProtocol("https", authhttps);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (GeneralSecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// ProtocolSocketFactory easy = new EasySSLProtocolSocketFactory();
// Protocol protocol = new Protocol("https", easy, 8443);
// Protocol.registerProtocol("https", protocol);
}
}
and here is the camel-context:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:broker="http://activemq.apache.org/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd">
<bean id="MyRouteBuilder" class="tutorial.MyRouteBuilder"></bean>
<camel:camelContext id="camelContext">
<camel:routeBuilder ref="MyRouteBuilder"/>
</camel:camelContext>
<bean id="HttpClientConfigurer" class="tutorial.HttpClientConfigurer">
</bean>
</beans>
and my route builder is :
from("mina:tcp://0.0.0.0:9002?sync=true&lazySessionCreation=true&minaLogger=true&textline=true&encoderMaxLineLength=50000&decoderMaxLineLength=50000&textlineDelimiter=WINDOWS&encoding=US-ASCII")
.process(new transformationProcessor())
.to("https://"+strIP+"/?httpClient.authenticationPreemptive=true&httpClientConfigurerRef=HttpClientConfigurer");
I'm using camel 2.2.0 and I use not-yet-commons-ssl version 0.3.11. I can
send you the whole pom.xml if you want.
I think that this problem has to do with not-yet-commons-ssl since, I have
searched for this error and the closest I found is:
http://old.nabble.com/No-private-keys-found-in-keystore-td18165598.html
both the keystore and the trust store files and password are running
correctly in an older application using System properties e.g.
System.setProperty("javax.net.ssl.keyStore", "ClientKey.jks"); and the
Security.addProvider( new com.sun.net.ssl.internal.ssl.Provider() );
Any suggestions?
--
View this message in context:
http://old.nabble.com/http-component-SSL-problem-tp28733226p28733226.html
Sent from the Camel - Users mailing list archive at Nabble.com.