Open giordanocardillo opened 4 years ago
Hi,
Thanks for providing a fix for the screen-lock issue !
After adding your code to my project, the console shows a different error after deleting the key and executing the init method again:
Error: KeyStore doesn't contain alias: xxxx
It looks like the key has been removed but doesn't get re-instantiated...
I did some debugging and found an issue in the 'init' method.
The key should be created through the generateEncryptionKeys method.
Instead, it doesn't pass the following line of code:
if (storage.isEmpty()) { //Solves Issue #96. The RSA key may have been deleted by changing the lock type. getStorage(INIT_SERVICE).clear(); rsa.createKeyPair(getContext(), alias, userAuthenticationValidityDuration); }
Since the 'sharedPreferences' folder doesn't get cleared, the key wont be generated.
No idea why this IF statement is required but removing it fixes the issue...
@aximobile how did you solve it? removing only the if statement? did you keep these two lines?
getStorage(INIT_SERVICE).clear();
rsa.createKeyPair(getContext(), alias, userAuthenticationValidityDuration);
Thanks!!
Customers were complaining that device would infinitely ask device password/PIN if they changed it.
I found out that initializing secure storage was bringing to the reuse of the same key, which was permanently invalidated from android system.
I created a method to delete the key if there is a KeyPermanentlyInvalidatedException, therefore the plugin will initialize a new key.