To accept self-signed certificates, we use the following code for a specific HttpConnection from a common http client.
HttpConnection con = new HttpConnection(host, port); con.setProtocol(new Protocol("easyhttps", (ProtocolSocketFactory)new EasySSLProtocolSocketFactory(), port));
EasySSLProtocolSocketFactory can be found in contrib ssl package. And this can be used to create only individual connections with a reduced security setting. It seems that this can also be used to set the protocol for each client, as shown here:
Protocol easyhttps = new Protocol("https", (ProtocolSocketFactory)new EasySSLProtocolSocketFactory(), 443); Protocol.registerProtocol("https", easyhttps); HttpClient client = new HttpClient(); GetMethod httpget = new GetMethod("https://localhost/"); client.executeMethod(httpget);
But I think this will also affect connections to other servlets.
[Edit] Sorry, I don't know if this will work for you. Just admitted that we are using client 3.0.1, not 3.1.
Gandalf
source share