So, I am trying to make an SSL request using HttpClient 4.5.3 to a PuppetDB endpoint, which is signed with it's own cert. The following cUrl query from the docs works fine:
curl -X GET https://hostname:8081/pdb/query/v4/resources \
--tlsv1 \
--cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem \
--cert /etc/puppetlabs/puppet/ssl/certs/hostname.pem \
--key /etc/puppetlabs/puppet/ssl/private_keys/hostname.pem \
--data-urlencode query@query.txt
I tried the documentation here, but that isn't working. Most examples I find online are HttpClient < 4.3, and all of those methods are deprecated. I tried allowing all certs with the following:
SSLContextBuilder sshbuilder = new SSLContextBuilder();
sshbuilder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sshbuilder.build());
try(CloseableHttpClient httpclient = HttpClients.custom()
.setSSLSocketFactory(sslsf)
.build()) {
HttpGet get = new HttpGet(uri);
httpclient.execute(get, (ResponseHandler<Void>) response -> {
StatusLine line = response.getStatusLine();
int code = line.getStatusCode();
logger.println("Response code: " + code);
return null;
});
}
which returns:
Executor #0 for master : executing test #44, WRITE: TLSv1 Handshake, length = 48
Executor #0 for master : executing test #44, received EOFException: error
Executor #0 for master : executing test #44, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
%% Invalidated: [Session-1, TLS_RSA_WITH_AES_128_CBC_SHA]
Executor #0 for master : executing test #44, SEND TLSv1 ALERT: fatal, description = handshake_failure
Executor #0 for master : executing test #44, WRITE: TLSv1 Alert, length = 32
Executor #0 for master : executing test #44, called closeSocket()
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
Any help would be great. Thanks!