I get this strange error from my java code:
java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
The command I used to create the keystore:
keytool -genkey -alias tomcat -keystore keystore.jks
Here is my Java code:
import java.security.cert.PKIXParameters;
import java.security.KeyStore;
import java.io.FileInputStream;
public class MyKeyTest {
public static void main(String[] args) throws Exception {
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
String password = "mypass";
ks.load(new FileInputStream("keystore.jks"), password.toCharArray());
new PKIXParameters(ks);
}
}
I tried google for this error, but basically it says that this happens when the keystore is not found or not allowed to read.
But none of these two cases is true in my case. Any ideas?
source
share