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

Bug on Android 4.4.2 #2

Closed
ghost opened this issue Feb 9, 2018 · 4 comments
Closed

Bug on Android 4.4.2 #2

ghost opened this issue Feb 9, 2018 · 4 comments

Comments

@ghost
Copy link

ghost commented Feb 9, 2018

While trying to run my flutter application on an Android 4.4.2 phone, I receive the following error:

E/FlutterSecureStoragePl(27505): Registration failed
E/FlutterSecureStoragePl(27505): java.lang.NullPointerException: chain == null
E/FlutterSecureStoragePl(27505): at java.security.KeyStore$PrivateKeyEntry.(KeyStore.java:1205)
E/FlutterSecureStoragePl(27505): at java.security.KeyStoreSpi.engineGetEntry(KeyStoreSpi.java:374)
E/FlutterSecureStoragePl(27505): at java.security.KeyStore.getEntry(KeyStore.java:644)
E/FlutterSecureStoragePl(27505): at com.it_nomads.fluttersecurestorage.ciphers.StorageCipher18Implementation.createKeysIfNeeded(StorageCipher18Implementation.java:78)
E/FlutterSecureStoragePl(27505): at com.it_nomads.fluttersecurestorage.ciphers.StorageCipher18Implementation.(StorageCipher18Implementation.java:29)
E/FlutterSecureStoragePl(27505): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.(FlutterSecureStoragePlugin.java:44)
E/FlutterSecureStoragePl(27505): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.registerWith(FlutterSecureStoragePlugin.java:32)
E/FlutterSecureStoragePl(27505): at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:21)

How can I fix this? It works perfectly on other Android versions.

@mogol
Copy link
Collaborator

mogol commented Feb 10, 2018

I can't reproduce this issue, but I found similar issue on StackOverflow

Could you try this fix - make KEY_ALIAS unique between apps ?

public class StorageCipher18Implementation implements StorageCipher {

  private final String KEY_ALIAS;
  private static final String KEYSTORE_PROVIDER_ANDROID = "AndroidKeyStore";
  private static final String TYPE_RSA = "RSA";


  public StorageCipher18Implementation(Context context) throws Exception {
    KEY_ALIAS = context.getPackageName() + ".FlutterSecureStoragePluginKey";
    createKeysIfNeeded(context);
  }

@ghost
Copy link
Author

ghost commented Feb 15, 2018

Thanks, this fixed a large part of it, at least for the release builds. It still occurs sometimes at debug mode, but this is fine for me.

@mogol
Copy link
Collaborator

mogol commented Feb 15, 2018

Great, will release this fix

@mogol
Copy link
Collaborator

mogol commented Mar 1, 2018

Published fix as 2.0.0.

@mogol mogol closed this as completed Mar 1, 2018
doznAvokado pushed a commit to doznAvokado/flutter_secure_storage that referenced this issue Jan 10, 2023
@Aggie85 Aggie85 mentioned this issue Sep 1, 2023
dballance referenced this issue in Tango-Tango/flutter_secure_storage Aug 7, 2024
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