This question is addition to my previous question How to import RSA private key, which generated by openssl, into AndroidKeyStore. I try to import my privateKey in KeyStore by the following way:
KeyStore ks = KeyStore.getInstance("AndroidKeyStore");
ks.load(null);
ks.setKeyEntry("myAlias", prKey, null, new Certificate[] {cert});
and I get an exception:
"java.lang.NullPointerException: Attempt to get length of null array"
And it is strange, because
prKey.getAlgorithm()
return correct algorithm.cert.getPublicKey().getAlgorithm()
also return correct algorithm.ks.size()
works correctly.
Key and Certificate were generated by:
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days XXX
openssl x509 -outform der -in cert.pem -out certificate.der
xxd -p certificate.der
So, think all parameters are correct, but why is it throw the exception?