flutter_secure_storage: Unhandled Exception: PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
Problem described in #161 still occurrs in 3.3.5.
E/flutter (29195): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
E/flutter (29195): at com.android.org.conscrypt.NativeCrypto.EVP_CipherFinal_ex(Native Method)
E/flutter (29195): at com.android.org.conscrypt.OpenSSLCipher$EVP_CIPHER.doFinalInternal(OpenSSLCipher.java:570)
E/flutter (29195): at com.android.org.conscrypt.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:351)
E/flutter (29195): at javax.crypto.Cipher.doFinal(Cipher.java:1741)
E/flutter (29195): at com.it_nomads.fluttersecurestorage.ciphers.StorageCipher18Implementation.decrypt(StorageCipher18Implementation.java:91)
E/flutter (29195): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.decodeRawValue(FlutterSecureStoragePlugin.java:163)
E/flutter (29195): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.read(FlutterSecureStoragePlugin.java:144)
E/flutter (29195): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.access$300(FlutterSecureStoragePlugin.java:29)
E/flutter (29195): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin$MethodRunner.run(FlutterSecureStoragePlugin.java:197)
E/flutter (29195): at java.lang.Thread.run(Thread.java:764)
E/flutter (29195): , null)
In my case for: Samsung S8 (Android 8)
Some others mention this behavior for:
- Pixel 4a
- Pixel 5 (Android 11)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 28
Hey guys I am not sure this issue should remain closed, it just happened to us in the production environment and it has never happened before. This is a very random issue that might randomly affect real users.
I was able to reproduce this issue with my Galaxy A40 (Android 10):
The error did not occur anymore after I deleted the App-Data (Settings>App>Storage>“Clear App Data”).
Seems like this is an restoring issue from some devices. I’ll try to overcome this issue by adding the:
flags in the AndroidManifest.xml (see https://github.com/mogol/flutter_secure_storage/issues/43#issuecomment-471642126)
Still an issue.
Facing same issue with flutter_secure_storage: ^4.2.0 in Android 11.
Hi guys, it’s happening here with 3.3.5 too. Maybe this issue shouldn’t be closed ¿?
Happening to me too, 4.1 Only when I reinstall the application outside of debugging (APKs or Play store) I have the backup flags set to false but they’re not helpnig, only fix is clearing cache.
------Edit For anyone having this issue, a work-around is installing SharedPreferences and emptying storage in the first bit of code that runs in your project `final prefs = await SharedPreferences.getInstance();
if (prefs.getBool(‘first_run’) ?? true) { FlutterSecureStorage storage = FlutterSecureStorage();
await storage.deleteAll();
prefs.setBool(‘first_run’, false); }`
Thanks to this guy.
I have opened a new issue to track this #354
Hi guys, I encountered the same issue recently, I am using FlutterSecureStorage.
while using it, please make sure you are passing the AndroidOptions while initializing the instance.
Instead of :
var secureStorage = const FlutterSecureStorage();
try adding as :
AndroidOptions androidOptions = const AndroidOptions( encryptedSharedPreferences: true, ); var secureStorage = FlutterSecureStorage( aOptions: androidOptions, );
Pass AndroidOptions while initializing the instance of FlutterSercureStorage. and mark encryptedSharedPreference to true.
This change actually resolved my issue.
Hope this helps someone.
Thanks.
Still an issue.
flutter_secure_storage 9.0.0 in Android 9.
Yes, I believe this happens, because the used keys change when the user re-installs the app or uses a different device.
I have not investigated it further though, but it would certainly make sense.
All I know is that after clearing the App data the error does not ocurr anymore.
The authors mentioned that the Android backup feature could cause problems (see https://github.com/mogol/flutter_secure_storage#configure-android-version), but not for this issue. Maybe it would be good to mention this issue as well.