Open gamestap99 opened 6 months ago
Error -25308 is errSecInteractionNotAllowed.
You might want to read this post on the Apple Developer Forums.
Can you give us some more context, i.e. the OS, version etc.?
@techouse Oke. Project using :
facing the same issue
flutter version: 3.19.3 flutter_secure_storage: 9.2.2
@gamestap99 Can you replicate this on a simulator or provide us with some sample code that replicates this error?
Does it work with v9.0.0 using something like this?
dependency_overrides:
flutter_secure_storage: 9.0.0
flutter_secure_storage_linux: 1.2.0
flutter_secure_storage_macos: 3.0.1
flutter_secure_storage_platform_interface: 1.0.2
flutter_secure_storage_windows: 3.0.0
flutter_secure_storage_web: 1.2.0
Facing the Same Issue
FLutter: 3.22.0
flutter_secure_storage: ^9.2.1
Device: Iphone 15 Pro IOS(v17.4.1)
Same issue for one customer, bug not always flutter_secure_storage: 9.2.2 iOS 16.7.8
Same issue for some customers, bug not always, after read data when device was unlocked flutter_secure_storage: 9.2.2
iOS 17.5.1 - 43,75 % iOS 17.4.1- 31,25 % iOS 16.5 - 25 %
This issue is replicable by reading from a secure storage(keychain) when a device is locked and has a passcode.
It can be fixed with:
final _storageProvider = FlutterSecureStorage(
iOptions: IOSOptions.defaultOptions.copyWith(
accessibility: KeychainAccessibility.first_unlock_this_device,
synchronizable: true,
),
);
Note:
Without providing synchronizable: true
it throws the errSecDuplicateItem
platform exception for me.
Issue disappeared when I downgraded the library:
dependency_overrides:
# Downgrade secure storage to 9.0.0 as version 9.2.2 has introduced some crashes on iOS
# The error description is "Unexpected security result code, Code: -25308"
flutter_secure_storage: 9.0.0
flutter_secure_storage_linux: 1.2.0
flutter_secure_storage_macos: 3.0.1
flutter_secure_storage_platform_interface: 1.0.2
flutter_secure_storage_web: 1.1.2
flutter_secure_storage_windows: 3.0.0
This issue is replicable by reading from a secure storage(keychain) when a device is locked and has a passcode.
It can be fixed with:
final _storageProvider = FlutterSecureStorage( iOptions: IOSOptions.defaultOptions.copyWith( accessibility: KeychainAccessibility.first_unlock_this_device, synchronizable: true, ), );
Note: Without providing
synchronizable: true
it throws theerrSecDuplicateItem
platform exception for me.
What are the consequences of doing this?
This issue is replicable by reading from a secure storage(keychain) when a device is locked and has a passcode. It can be fixed with:
final _storageProvider = FlutterSecureStorage( iOptions: IOSOptions.defaultOptions.copyWith( accessibility: KeychainAccessibility.first_unlock_this_device, synchronizable: true, ), );
Note: Without providing
synchronizable: true
it throws theerrSecDuplicateItem
platform exception for me.What are the consequences of doing this?
https://developer.apple.com/documentation/security/ksecattraccessibleafterfirstunlock
@mogol, please, can you explain why this happens and can it be fixed by someone?
We are also getting that crash after upgrading to the v9.2.2 version.
Facing same issue on latest version.
Facing same issue as well on latest version for some iOS devices with the options fix set.
IOSOptions _getIOSOptions() => const IOSOptions( accessibility: KeychainAccessibility.first_unlock, synchronizable: true, accountName: 'myapp_prefs', );
await _secureStorage.write(key: newItem.key.name, value: newItem.value, aOptions: _getAndroidOptions(), iOptions: _getIOSOptions());
Having the same issue with this initialization but only in release
mode in my live app :
final FlutterSecureStorage _secureStorage = const FlutterSecureStorage(
aOptions: AndroidOptions(
encryptedSharedPreferences: true,
),
iOptions: IOSOptions(synchronizable: false)
);
I changed my usage from
final storage = const FlutterSecureStorage(aOptions: AndroidOptions(encryptedSharedPreferences: true));
to
final _storage = const FlutterSecureStorage(
aOptions: AndroidOptions(encryptedSharedPreferences: true),
iOptions: IOSOptions(
accessibility: KeychainAccessibility.first_unlock_this_device,
synchronizable: true,
),
);
Seems the problem didn't happen but behaved values aren't stored anymore before!
Seems the problem didn't happen but behaved values aren't stored anymore before!
When changing the settings, you need to "migrate" values from the previous settings. I described this in a similar issue.
Seems the problem didn't happen but behaved values aren't stored anymore before!
When changing the settings, you need to "migrate" values from the previous settings. I described this in a similar issue.
I've just reviewed your metod, it simply uses secure storage first, then uses legacy (shared prefs imho) if secure storage fails. This means same values are stored (must be stored) in secure storage and legacy options both, otherwise this fallback does not work.
In my scenario,
To make work your scenario i would be storing those credentials in "legacy" option too :/
I've just reviewed your metod, it simply uses secure storage first, then uses legacy (shared prefs imho) if secure storage fails. This means same values are stored (must be stored) in secure storage and legacy options both, otherwise this fallback does not work.
No, it's using secure storage in both cases. "Legacy" refers to the secure storage being created/accessed with the old settings. Here's the associated code:
Yes, my mistake. Both storages are indeed FlutterSecureStorage.
Based on your latest post, it looks like _legacyStorage
is the one I’ve already been using, and it’s throwing the 25308 exception.
I also tried _storage
(as I mentioned in my first post), but it returns empty for all my keys.
To sum up, using _storage
first and getting an empty result, then trying _legacyStorage
and getting the 25308 exception, doesn't add up. How would this resolve the issue?
Yes, my mistake. Both storages are indeed FlutterSecureStorage.
Based on your latest post, it looks like
_legacyStorage
is the one I’ve already been using, and it’s throwing the 25308 exception.I also tried
_storage
(as I mentioned in my first post), but it returns empty for all my keys.To sum up, using
_storage
first and getting an empty result, then trying_legacyStorage
and getting the 25308 exception, doesn't add up. How would this resolve the issue?
In my case, if the app was restarted, the storage was accessible again...It was reading from the background that was messing things up. If in your case the "legacy" storage is fully borked and you can no longer read from it, migration may not be possible.
On a beautiful day, I received this token, and it seems that it caused my app to crash. To be more precise, I tried to catch the error, so it didn't take the main key, causing the session to log out. I am using it to encrypt the Hive NoSQL database.
my code using it