You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Myriam Khairallah <my...@atos.net> on 2013/01/25 10:36:50 UTC
Re: HTTP4 Client + SSL + Accept All Hostnames + Accept All
certificates
Hi,
I need to do exactly the same as described in this topic, but it doesn't
work for me, neither with camel 2.8.0 nor with the newer camel version
2.10.3 - I still get "javax.net.ssl.SSLPeerUnverifiedException: peer not
authenticated".
Here is what I did:
My own HttpClientConfigurer:
public class MyHttpClientConfigurer implements HttpClientConfigurer {
@Override
public void configureHttpClient(HttpClient client) {
try {
SSLContext ctx = SSLContext.getInstance("SSL");
X509TrustManager tm = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] xcs,
String string) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] xcs,
String string) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
};
ctx.init(null, new TrustManager[] { tm }, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx,
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
client.getConnectionManager().getSchemeRegistry().register(new
Scheme("https4", 443, ssf));
client.getConnectionManager().getSchemeRegistry().register(new
Scheme("http", 80,
PlainSocketFactory.getSocketFactory()));
client.getConnectionManager().getSchemeRegistry().register(new
Scheme("http4", 80,
PlainSocketFactory.getSocketFactory()));
System.out.println("Bla");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
The entry in my camel context file:
<bean id="myHttpClientConfigurer" class="my.package.MyHttpClientConfigurer"
/>
The call of the URL in the route:
from("direct:login")
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.to("https4://my_url/index.jsp?httpClientConfigurer=myHttpClientConfigurer")
.end();
Am I missing something here ?
Thanks.
--
View this message in context: http://camel.465427.n5.nabble.com/HTTP4-Client-SSL-Accept-All-Hostnames-Accept-All-certificates-tp4549626p5726238.html
Sent from the Camel - Users mailing list archive at Nabble.com.