I am trying to access one HTTPS url from my local for which I have added the certificate in my cacerts using below command from cmd.
keytool -import -file "C:\Users\loren\customerapi.cer" -keystore "C:\Program Files\java\jdk1.8.0_25\jre\lib\security\cacerts" -storepass "changeit
I have put the cacerts file in same folder as my class and now trying to load cacerts in my project using below lines but it is throwing error -
System.setProperty("javax.net.ssl.trustStore", "cacerts.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)
at java.security.cert.PKIXParameters.<init>(PKIXParameters.java:120)
at java.security.cert.PKIXBuilderParameters.<init>(PKIXBuilderParameters.java:104)
at sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:88)
... 25 more
Moreover in my security folder I can see cacerts is of file FILE, isn't should be of type jks?