I'm trying to load PrivateKey from .p12 file by using this code:
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
java.security.KeyStore keyStore = KeyStore.getInstance("PKCS12", "BC");
keyStore.load(new FileInputStream(new File("my_domain_com.p12")), password);
keyStore.aliases().hasMoreElements(); //this is false
java.security.PrivateKey privateKey = (PrivateKey) keyStore.getKey("SomeAlias", password);
I'm trying to find the reason why there is no aliases. But I'm not able to find. What can be reason for the empty alias? I want to get private key and ecrypt some text using this key. Is there other apporach?
I also have .cer file but I'm not sure I should use together.