I have the location of certificate. Can someone guide me on how to add certificate to the HTTP header in RestTemplate. Below is how I am building the RestTemplate. The certificate needs to be in a header by name ssl-client-cert. Should this be done in the code or configures on the web server?
public RestTemplate restTemplate(RestTemplateBuilder builder) throws Exception {
SSLContext sslContext;
KeyStore keystore = KeyStore.getInstance("JKS");
FileInputStream ks = new FileInputStream("<path>");
FileInputStream ts = new FileInputStream("<path>");
keystore.load(ks,"changeit".toCharArray());
KeyStore truststore = KeyStore.getInstance("JKS");
truststore.load(ts,"changeit".toCharArray());
sslContext = SSLContextBuilder.create()
.loadKeyMaterial(keystore, global.getstorePass().toCharArray())
.loadTrustMaterial(truststore, new TrustSelfSignedStrategy())
.build();
HttpClient client = HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.build();
return builder.requestFactory(new HttpComponentsClientHttpRequestFactory(client))
.build();
}