I want to connect to a secure server endpoint. The service provider has provided me with a .p12 file and the password. I tried the API call on postman after adding the certificate under settings --> certificates--> client certificates and it was a success.
Now I want to integrate this to my java code. I am developing this application using Spring boot and I followed a couple of guides for this.I added the the .p12 file to my keystore using this command.
keytool -importkeystore -srckeystore uat_client.p12 -destkeystore store.keys -srcstoretype pkcs12 -alias myownkeyname
But every time I get "No SSL Client Certificate Provided"which is the same response I got when I did not add the certificate in the postman.
I know this is not the ideal way to ask help since I do not have much code to show.And I am very new to this area of java. I am merely asking for some guide. If I have a .p12 file what are the steps I need to follow to connect to the service successfull.
public void someMethod()
{
RestTemplate restTemplate = new RestTemplate();
HttpHeaders httpHeaders = new HttpHeaders();
String uri = "https://xx.net/api/v2/somemethod";
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
String result = restTemplate.getForObject(uri, String.class);
System.out.println("Result " + result);
}