I have been given the following key/cert from a service team to call their API over SSL, which I verfied thru curl command.
1. QA.test.key
2. QA.test.pem
CURL command:
curl --key QA.test.key --cert ./QA.test.pem -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d '{"pan":"1234567890123456", "client": " Application Name "}' https://test-qa.abc.com/tokenize
Now, to call the API in Java over https, do I need to do the following?
- Create a self signed jks file
- import the .key and .pem to new test.jks file?
Do the following
public class TestApp { final static String KEYSTORE_PASSWORD = "testing"; static { System.setProperty("javax.net.ssl.trustStore", "src/main/resources/test.jks"); System.setProperty("javax.net.ssl.trustStorePassword", KEYSTORE_PASSWORD); System.setProperty("javax.net.ssl.keyStore", "src/main/resources/test.jks"); System.setProperty("javax.net.ssl.keyStorePassword", KEYSTORE_PASSWORD); } public static void main(String[] args) { SpringApplication.run(TestApp.class, args); }
}
I am getting Invalid Certificate error while using the jks file, what would be the best way to create a jks file and import .key and .pem file for it to work properly?