Skip to content

Instantly share code, notes, and snippets.


Judd Flamm juddflamm

View GitHub Profile
juddflamm / gist:5391938
Last active Jul 13, 2018
Enabling 2 Way SSL Client Service Calls from within Dropwizard. To do so, you need to load your keystore and truststore and configure HttpClient to us them for HTTPS calls. In this case, my keystore and truststore are the same file with the same password. (Thanks to Coda Hale for an initial solution)
View gist:5391938
//First create the httpClient in Dropwizard's run method as documented
final HttpClient httpClient = new HttpClientBuilder().using(configuration.getHttpClient()).build();
try {
//Create KeyStore obejcts for both the keystore and truststore
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
KeyStore truststore = KeyStore.getInstance(KeyStore.getDefaultType());
//Then load the actual keystore/truststore file(s), they are the same file in my case
keystore.load(new FileInputStream(configuration.getKeyStore()), configuration.getKeyStorePassword().toCharArray());