UnrecoverableKeyException Failed to obtain information about private key, KeyStoreException: Invalid key blob UnrecoverableKeyException Failed to obtain information about private key, KeyStoreException: Invalid key blob android android

UnrecoverableKeyException Failed to obtain information about private key, KeyStoreException: Invalid key blob


I also faced issues with stability in KeyStore.

The solution was to use for private key

PrivateKey privKey = ks.getKey(alias, password)

And this to public key

PublicKey pubKey = ks.getCertificate(alias).getPublicKey();

instead of getEntry

ks.getEntry(alias, password)

The problem wasn't in the way you're creating the key but the way you're reading it.

Over more than a year never saw this issue again.