-
Notifications
You must be signed in to change notification settings - Fork 404
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
PlatformException (PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT #541
Comments
I have a similar issue |
Does the author have any solutions? 😸 |
I have a similar issue |
We are seeing the same issue BUT only when building release appbundle and upload to playstore Not working:
Working:
? |
have you tried final FlutterSecureStorage storage = const FlutterSecureStorage( |
The same issue was obtained just at the Samsung device (Galaxy S22+). Android 12. Let's look deeper... Adding of the |
I have exactly the same issue described above, in the same conditions mentionned by @devswingapplicationcom. To temporarily solve the problem, I clear the secure storage the first time the user installs a new version. I call the following code at startup: String version = // current version of your app, e.g. 1.0.0
if (sharedPreferences.getString("secureStorageCleared") != version) {
await flutterSecureStorage.deleteAll();
await sharedPreferences.setString("secureStorageCleared", version);
} This will be called only once per new version. |
Also had this issue, only got this error when built release and installed via play store, not an issue debugging locally, and issue only on Android, not iOS Clearing the data fixed the issue for me but not a great work-around |
Had the same issue previously. I am fairly certain that at least some Samsung devices sometimes ignore the following Android flags: android:allowBackup="false"
android:fullBackupContent="false" What this means is that some Samsung phones store (locally / or on some google/samsung server) app data when the app is deleted ; and it restores it when the app is re-installed. However, the padding encryption key DOES NOT leave the device and is deleted when the app is initially deleted. When the user re-installs the app, a new encryption key is generated/returned. The app will attempt to decrypt the old restored data with the new encryption key, leading to the My recommendation (and what I am doing) is to clear all encrypted data when encountering this exception and start fresh. If you encounter this, the existing encrypted data is almost certainly permanently lost anyways, since the decryption key does not exist anymore. |
This problem seems to occur only on SM-G991B (S21) and SM-G996B (S21+). |
I tried this, but the users encounter this exception EVERY time the app is terminated and reopened, not just with a reinstall or a update. |
Hey @frankmer, how can i test it? I tried a lot of times but never get success, can't found any log or reference using browser Stack. But a lot of user have been sending a bad review about this issue. |
Has anyone tested using the resetOnError flag (AndroidOptions )? Maybe it can be an internal solution that we don't need to do the try catch in flutter side. |
I never tested it on a real device, but I was able to simulate this error by adding an old FlutterSecureStorage.xml to shared_prefs after deleting the appdata. Our customer report only came from these devices, and there were a lot of them. SM-G998B (S21 Ultra) is now also on the list. |
The real question is whether the error has occurred since or because of the software update. Even if deleting the old data is not a good option. It would be nice to know if this is actually an option or if the error still occurs. |
How can I do it? (change the flutterSecureStorage.xml) ? Can you provide a short guide or share any reference? :) Will be very important simulate it here. |
Using deleteAll and writing something to the secure storage again causes the Exception to be thrown again when our Users are terminating the app and reopening it after. So it seems that the corruption of the data is not a one-time event after the update, but it is completely broken since. |
I did it via Android Studio. Device Manager > Run Device > Folder Button under Actions. Then use "Save As..." and "Upload..." Files found in data/data/{appid}/shared_prefs |
@frankmer thanks for your guide. I did simulate and get the same log error, but the application on device emulator keeps working fine. I saw in the last threads that it crash only in release mode... So its difficult to prevent anything from our side. |
Can anyone test if this error still occurs when the application is uninstalled and then reinstalled? Some customers say this fixes the problem. |
That is interesting, the first thing we recommended to our customers was to reinstall the app but that didn't seem to help them.. This is how we have it in our app:
With in the backup_rules:
This was the solution when we encountered this problem a few years back, see: |
The current problem has nothing to do with the old problem from a few years ago. If reinstalling really fixes it, then my guess is that the link between the key and the application itself is broken, and reinstalling the application will reestablish that link. Although reinstalling may cause the other problem if backup is enabled. |
I dont think that the changes on android 12 will impact on this error because they are for the d2d backup. |
I really think that this is the point. Because here the backup is enabled and the reinstall isnt working. So we are changing to false and we will check in the next release. :) |
android:fullBackupContent="false" indeed fixed all our problems, thanks! 😄 |
the try catch suggestion was not necessary? :) |
Instead of doing
Shouldn't it be: For Android up to 11:
For Android 12 and up:
As I see that:
|
What worked for me was this: AndroidManifest.xml
And as @PieterAelse pointed out:
I'm on |
@bqubique Do we need to include data-extraction-rules if |
@vodemn I just had a read of this [https://developer.android.com/guide/topics/data/autobackup](Back up user data with Auto Backup), and seems like there's no need for the separate data-extraction-rules file. I can't recall if I tried that, but that should've been the very first thing I would try so I'm guessing I already tried that but it did not work. Our issue wasn't evident on every type of device, my Pixel would work just fine i.e. delete the data after an uninstall, but for some reason Samsung devices had a different way of handling this issue, and in the end what I posted above worked perfectly. Right now though I have completely replaced |
resolved flutter_secure_storage: ^9.0.0 |
Still experiencing this issue and doing this does not resolve... |
Hope it can helps you! I am using
and it works fine until the
|
Has this been resolved yet? 🥹 |
Still hapening.. any news? |
okay that's works for me not sure it works on all devices 1 - clear the cache in the first run // main.dart
if (!CachingHelper.instance!.readBoolean(CachingKey.ONBOARDING)) {
CachingHelper.instance!.clearSecrets(); // <- Here I remove everything at the beginning (there is nothing stored yet)
} 2 - add this to the mainfist.xml file <application
android:label="Tasker"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:fullBackupContent="false"
> 3 - Used version flutter_secure_storage: ^9.2.2 |
Any updates? |
Im closing this as duplicate of #354 |
The reason is clearly because of this. You can try clearing app data and try, it will work.
|
same issue |
1 similar comment
same issue |
same |
Hi,
I have upgraded to latest secure storage plugin flutter_secure_storage: 8.0.0.
Below is the complete error.
How I initialise and use the flutter secure storage is like below. I keep in in a global file like below. I call the file as authcheck.
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
class AuthCheck{
static const String partnerIdKey = 'partnerIdKey';
static const storage = FlutterSecureStorage(
aOptions: AndroidOptions(
encryptedSharedPreferences: true,
),
);
static Future<String?> getPartnerID() async {
String? partnerIdKey = await storage.read(key: 'partnerIdKey');
return partnerIdKey;
}
static insertDetails(String partnerID) async {
}
}
So which ever page I need to insert or read the value I just insert this page example like this import 'authcheck.dart'; I have been working smoothly in most of my apps but suddenly this errors. IF you see I have also put this option encryptedSharedPreferences: true. What else I could be missing from end ?
The text was updated successfully, but these errors were encountered: