Below is my code for getting private key from Keystore file.
BouncyCastleProvider provider = new BouncyCastleProvider();
Security.addProvider(provider);
System.err.println(KeyStore.getDefaultType());
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(new FileInputStream("src/main/resources/xxx.jks"), PASSWORD);
String alias = "xxxxxxx";
PrivateKey pk = (PrivateKey) ks.getKey(alias, PASSWORD);
System.err.println(pk);
I am giving right values for alias and password. But I am getting null in private key.
Why I am getting null, Is there any alternative approach to get private key from jks file.
Any help will be greatly appreciated!!
My question is not able to get the private key. But the mentioned question is the incorrect key