How do I pass the client certificate with HTTP client?

apache, apache-commons-httpclient, https, ssl, ssl-certificate

Solution

You need to tell an SSLSocketFactory (org.apache.http, not javax) about your keystore, and configure your DefaultHTTPClient to use it for https connections.

An example is here: http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientCustomSSL.java

Problem

I want to use mutual SSL authentication between service A and B. I'm currently implementing passing the client certificate from service A in Java. I'm using Apache DefaultHttpClient to execute my requests. I was able to retrieve the client certificate for my service A from an internal credential manager and I keep it as an array of bytes. ``` DefaultHttpClient client = new DefaultHttpClient(); byte [] certificate = localCertManager.retrieveCert(); ``` I have very little experience in this area and I'd appreciate your help! I thought maybe it should be somehow passed through arguments in the HTTP client or maybe in the headers. How do I pass the client certificate with HTTP client?

Original source

Related problems