Closed RANSoftRA closed 3 years ago
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:
android:allowBackup="false"
android:fullBackupContent="false"
flags in the AndroidManifest.xml (see https://github.com/mogol/flutter_secure_storage/issues/43#issuecomment-471642126)
Issue was resolved the following way:
Created a new version for the app:
android:allowBackup="false"
android:fullBackupContent="false"
IMHO this is not an flutter_secure_storage issue. The backup content features should not include sensitive information that should only be stored on the device / used in the same application instance.
@RANSoftRA one of our users has the same problem with a Huawei mate 20 lite. I added the fullBackupContent=false, (allowBackup="false" was already added.)
What error should I catch? And when should I catch the error?
In my case the error occurred during the login process - it threw a PlattformException.
Example - Code In the Widget (so I can display an appropriate Error):
class LoginForm extends StatefulWidget {
...
// login - form submit
Future<void> _submit(BuildContext context) async {
final authProvider = Provider.of<AuthProvider>(context, listen: false);
try {
// Performs a FlutterSecureStorage().write('...', '...') at some point
await authProvider.login(_loginData['email'], _loginData['password']);
....
} on PlatformException catch (e) {
_setErrorState(message: 'Please clear App Data');
} catch (e) {
// Handling other errors
....
}
...
}
...
}
Do you have an idea why it is required to remove the app data for all users who are experiencing this?
For me the issue is happening on a FlutterSecureStorage.read
.
Not sure why this is happening? Is it because when the app is reinstalled the secure store is used. but the keys for opening the secure store are different?
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.
Alright. probably a delete & reinstall will fix the issue as well.
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.
Hi guys, it's happening here with 3.3.5 too. Maybe this issue shouldn't be closed ¿?
It's failing on my Pixel 3, but works fine on my Pixel 4a. I'm running flutter_secure_storage version 3.3.5, clean install of app on both phones, production build of app (not debug).
I do not have these flags:
android:allowBackup="false"
android:fullBackupContent="false"
Update: It makes no difference whether the above flags are true or false.
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 am using version 3.3.5 in the production and since few days ago I started getting sentry reports with following error log:
PlatformException
PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
at com.android.org.conscrypt.NativeCrypto.EVP_CipherFinal_ex(Native Method)
at com.android.org.conscrypt.OpenSSLEvpCipher.doFinalInternal(OpenSSLEvpCipher.java:152)
at com.android.org.conscrypt.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:374)
at javax.crypto.Cipher.doFinal(Cipher.java:2055)
at c.c.a.b.b.b(Unknown Source:32)
at c.c.a.a.b(Unknown Source:11)
at c.c.a.a.d(Unknown Source:7)
at c.c.a.a.a(Unknown Source:0)
at c.c.a.a$b.run(Unknown Source:134)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.os.HandlerThread.run(HandlerThread.java:67)
, null)
I tried to reproduce the bug, and I manage to do it. Devices that I have tested it Samsung s9 and Samsung s10e => error, Huawei P20 Pro is working and not crashing. As mentioned above
D/FlutterSecureStoragePl( 7250): Initializing StorageCipher
I/fluttersecurestorage( 7250): Creating keys!
I/fluttersecurestorage( 7250): Initializing
I/fluttersecurestorage( 7250): Generating key pair
E/KeyStore( 7250): generateKeyInternal failed on request -68
D/CertificatePolicyCache( 7250): Creating new instance of CertificatePolicyCache myUid: 10444 callingUid: 10444
D/CertificatePolicyCache( 7250): readVariables type: null userId: 0
D/FlutterSecureStoragePl( 7250): StorageCipher initialization complete
I don't know if this log is helpful, but this is actually a really huge bug.
Facing same issue with flutter_secure_storage: ^4.2.0 in Android 11.
I have same issue with flutter_secure_storage: ^4.2.0 in Android 11 on samsung s20.
Same issue with flutter_secure_storage: ^4.2.0
I'm having the same problem. It happens randomly and it never occured before. Please re-open the issue.
Still an issue.
Still an issue with the latest version. Issue can be reproduced with re-installing the app but only on specific devices @mogol
I have opened a new issue to track this #354
If the change to the manifest works please add to readme
Thanks a lot, This is works now.
Additional to Mentioned issue by @darshankawar
After changing
final FlutterSecureStorage _secure = const FlutterSecureStorage()
to
final FlutterSecureStorage _secure = const FlutterSecureStorage(aOptions: AndroidOptions(
encryptedSharedPreferences: true,
))
the problem still exisits but changes to
PlatformException(Exception encountered, readAll, java.lang.SecurityException: Could not decrypt key. decryption failed at androidx.security.crypto.a.c(Unknown Source:58) at androidx.security.crypto.a.getAll(Unknown Source:49) at x3.a.m(Unknown Source:5) at x3.e$b.run(Unknown Source:204) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.os.HandlerThread.run(HandlerThread.java:67) Caused by: java.security.GeneralSecurityException: decryption failed at t2.c$a.b(Unknown Source:138) at androidx.security.crypto.a.c(Unknown Source:13) at androidx.security.crypto.a.getAll(Unknown Source:49) at x3.a.m(Unknown Source:5) at x3.e$b.run(Unknown Source:204) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.os.HandlerThread.run(HandlerThread.java:67) , null)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:322)
<asynchronous suspension>
#2 MethodChannelFlutterSecureStorage.readAll (package:flutter_secure_stora
Still an issue.
flutter_secure_storage 9.0.0 in Android 9.
Got the issue randomly on Android 14 devices, LogCat shows following error in production app:
[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
at com.android.org.conscrypt.NativeCrypto.EVP_CipherFinal_ex(Native Method)
at com.android.org.conscrypt.OpenSSLEvpCipher.doFinalInternal(OpenSSLEvpCipher.java:152)
at com.android.org.conscrypt.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:374)
at javax.crypto.Cipher.doFinal(Cipher.java:2056)
at w6.h.b(Unknown Source:35)
at v6.a.c(Unknown Source:11)
at v6.a.k(Unknown Source:17)
at v6.e$b.run(Unknown Source:233)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.os.HandlerThread.run(HandlerThread.java:67)
, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167)
Happens in latest version too.
Delete cache/all data not works. Flags allowBackup and fullBackupContent "works."
Only in release mode build, debug works fine.
Android 9
03-13 12:11:51.415 29225 29245 E flutter : [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT 03-13 12:11:51.415 29225 29245 E flutter : at com.android.org.conscrypt.NativeCrypto.EVP_CipherFinal_ex(Native Method) 03-13 12:11:51.415 29225 29245 E flutter : at com.android.org.conscrypt.OpenSSLCipher$EVP_CIPHER.doFinalInternal(OpenSSLCipher.java:596) 03-13 12:11:51.415 29225 29245 E flutter : at com.android.org.conscrypt.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:363) 03-13 12:11:51.415 29225 29245 E flutter : at javax.crypto.Cipher.doFinal(Cipher.java:2055) 03-13 12:11:51.415 29225 29245 E flutter : at q4.h.b(Unknown Source:35) 03-13 12:11:51.415 29225 29245 E flutter : at p4.a.c(Unknown Source:11) 03-13 12:11:51.415 29225 29245 E flutter : at p4.a.l(Unknown Source:17) 03-13 12:11:51.415 29225 29245 E flutter : at p4.e$b.run(Unknown Source:235) 03-13 12:11:51.415 29225 29245 E flutter : at android.os.Handler.handleCallback(Handler.java:873) 03-13 12:11:51.415 29225 29245 E flutter : at android.os.Handler.dispatchMessage(Handler.java:99) 03-13 12:11:51.415 29225 29245 E flutter : at android.os.Looper.loop(Looper.java:207) 03-13 12:11:51.415 29225 29245 E flutter : at android.os.HandlerThread.run(HandlerThread.java:65) 03-13 12:11:51.415 29225 29245 E flutter : , null) 03-13 12:11:51.415 29225 29245 E flutter : #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651) 03-13 12:11:51.415 29225 29245 E flutter : #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334) 03-13 12:11:51.415 29225 29245 E flutter : <asynchronous suspension>
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.
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.
That's half true, besides it works on update on store, sometimes on uninstall and install run into problem again.
Not fixed at all, tested on Android 14 and 9
and this is related to targeting sdk level 34? i think i got my problem to go away by going back to 33 - but we have to go to 34 very soon.
On Tue, Apr 9, 2024 at 7:38 AM Rene Nucci @.***> wrote:
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.
That's half true, besides it works on update on store, sometimes on uninstall and install run into problem again.
Not fixed at all, tested on Android 14 and 9
— Reply to this email directly, view it on GitHub https://github.com/mogol/flutter_secure_storage/issues/210#issuecomment-2045087290, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXBGYO2U4LB75Z5N36QT5DY4POKRAVCNFSM4YD6HLL2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBUGUYDQNZSHEYA . You are receiving this because you commented.Message ID: @.***>
Any news? The issue happening
Having this issue as well. Have to upgrade and target sdk 34 in 45 days. Is there any news on this?
Any news on this?? I am still seeing this issue
I'm also facing the same issue. any updates
Any updates on this issue?
Android 14 users of my production app is facing problems. App is stuck on startup as i am using this package to fetch secure values. After clearing the cache manually it start working.
Ps:- We cant tell all the users to delete cache and run app. This is very bad.
This is a problem for us too
@mogol I think we might need to re-open this issue.
@dishankjindal1 How are you having them clear cache?
@bryan1anderson There’s another (already open) issue for this actually, #354. I opened it because this one was closed, so it’s still being tracked fwiw.
Based on the updates there, it might be fixed in an upcoming rewrite https://github.com/mogol/flutter_secure_storage/issues/769
Problem described in #161 still occurrs in 3.3.5.
In my case for: Samsung S8 (Android 8)
Some others mention this behavior for: