Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[native_storage] Reinstalling app throws KeyStoreException in NativeStorage().secure.isolated.read() #156

Open
rubenferreira97 opened this issue Jul 2, 2024 · 0 comments

Comments

@rubenferreira97
Copy link

rubenferreira97 commented Jul 2, 2024

While debugging, I uninstalled and installed my app, and the following exception appeared:

JniException (Exception in Java code called through JNI: javax.crypto.AEADBadTagException
...
android.security.KeyStoreException: Signature/MAC verification failed
...

After some investigation, I found that Android's backup policy is the culprit. It tries to back up old data, and since these cryptographic keys do not match, this error occurs.

For more context, a similar issue is discussed in this package: flutter_secure_storage#43.

Currently, there are two ways to fix this:

Option 1: Disable backup completely:

<application
    ...
        android:allowBackup="false">

Option 2: Keep backup enable but exclude encrypted data used by this plugin:

<application
    ...
        android:allowBackup="true" 
        android:fullBackupContent="@xml/backup_rules">
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
    <exclude <!-- What to place here ??? --> /> 
</full-backup-content>

This issue asks to get better documentation for this. I also want to ask how to solve this using Option 2, as I don't know what to exclude. Additionally, is it possible to add this exclude directive directly to the dependency itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant