Error while hitting 3rd party API from Spring boot app : the trustAnchors parameter must be non-empty

Viewed 320

I have a spring boot application (running on HTTPS but on self-signed cert). It uses JDK 1.8 (not open JDK) and I wrote down a code where my code is hitting 3rd party APIs. Earlier my code was working. But for some other task, I had to import Company provided certificate to make application HTTPS. For this, I changed keystore from JKS to PCKS12 standard.

Now after changing the keystore (I did this to enable my application HTTPS with company provided certificate), my code which hits 3rd party API is not working. This is throwing below error.

Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

Can you please help me how to fix this error. I checked on internet and found out that I should set up trust store in my application but not able how to do that.

1 Answers

Finally I was able to fix this. By Adding below lines in my code System.setProperty("javax.net.ssl.trustStore", "<classpath:file.p12>"); System.setProperty("javax.net.ssl.trustStorePassword","<pwd>"); System.setProperty("javax.net.ssl.truststoretype", "PKCS12");

Related