jeroentrappers / flutter_keychain Goto Github PK
View Code? Open in Web Editor NEWA flutter plugin for secure storage on Android via KeyStore and iOS via Keychain
License: Other
A flutter plugin for secure storage on Android via KeyStore and iOS via Keychain
License: Other
The plugin flutter_keychain
uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
Please update new version to fix it. Thanks
First, let me thank you for this library: great job!
One issue I have is this:
Looks like it does not work on 5.0 & 5.1 emulator (not sure about real devices) because of a suppressed class?
Suppressed: java.lang.ClassNotFoundException: android.security.keystore.KeyGenParameterSpec$Builder
I checked the Android Studio project folder of my Flutter app:
minSdkVersion 21
which is Android Lollipop (5.0)
I then dug into the code and found out that some code is commented in
C:\Users\<username>\flutter.pub-cache\hosted\pub.dartlang.org\flutter_keychain-1.0.0\android\src\main\kotlin\be\appmire\flutterkeychain\FlutterKeychainPlugin.kt
I uncommented and it seems to be working fine now.
Can you please fix or explain this?
Thanks
// if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
//
// spec = android.security.KeyPairGeneratorSpec.Builder( context)
// .setAlias(keyAlias)
// .setSubject(X500Principal("CN=$keyAlias"))
// .setSerialNumber(BigInteger.valueOf(1))
// .setStartDate(start.time)
// .setEndDate(end.time)
// .build()
// } else {
spec = KeyGenParameterSpec.Builder(keyAlias, KeyProperties.PURPOSE_DECRYPT or KeyProperties.PURPOSE_ENCRYPT)
.setCertificateSubject(X500Principal("CN=$keyAlias"))
.setDigests(KeyProperties.DIGEST_SHA256)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1)
.setUserAuthenticationRequired(false)
.setCertificateSerialNumber(BigInteger.valueOf(1))
.setCertificateNotBefore(start.time)
.setCertificateNotAfter(end.time)
.build()
// }
FYI, Stack trace with comment on (Android 5.x)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mytestapp, PID: 3910
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/security/keystore/KeyGenParameterSpec$Builder;
at be.appmire.flutterkeychain.RsaKeyStoreKeyWrapper.createKeys(FlutterKeychainPlugin.kt:156)
at be.appmire.flutterkeychain.RsaKeyStoreKeyWrapper.createRSAKeysIfNeeded(FlutterKeychainPlugin.kt:123)
at be.appmire.flutterkeychain.RsaKeyStoreKeyWrapper.<init>(FlutterKeychainPlugin.kt:48)
at be.appmire.flutterkeychain.FlutterKeychainPlugin$Companion.registerWith(FlutterKeychainPlugin.kt:280)
at be.appmire.flutterkeychain.FlutterKeychainPlugin.registerWith(FlutterKeychainPlugin.kt)
at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:15)
at com.mytestapp.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.security.keystore.KeyGenParameterSpec$Builder" on path: DexPathList[[zip file "/data/app/com.mytestapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mytestapp-1/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at be.appmire.flutterkeychain.RsaKeyStoreKeyWrapper.createKeys(FlutterKeychainPlugin.kt:156)
at be.appmire.flutterkeychain.RsaKeyStoreKeyWrapper.createRSAKeysIfNeeded(FlutterKeychainPlugin.kt:123)
at be.appmire.flutterkeychain.RsaKeyStoreKeyWrapper.<init>(FlutterKeychainPlugin.kt:48)
at be.appmire.flutterkeychain.FlutterKeychainPlugin$Companion.registerWith(FlutterKeychainPlugin.kt:280)
at be.appmire.flutterkeychain.FlutterKeychainPlugin.registerWith(FlutterKeychainPlugin.kt)
at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:15)
at com.mytestapp.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Suppressed: java.lang.ClassNotFoundException: android.security.keystore.KeyGenParameterSpec$Builder
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 21 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.2.51 and higher. Project 'flutter_keychain' is using version 1.2.30.
It seems flutter_keychain has no support for web.
Sometimes getting this error:
E/flutter_keychain(29852): error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): Failed to handle method call
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): java.lang.IllegalArgumentException: Unsupported value: javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:293)
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at io.flutter.plugin.common.StandardMethodCodec.encodeErrorEnvelope(StandardMethodCodec.java:70)
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:208)
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at be.appmire.flutterkeychain.FlutterKeychainPlugin.onMethodCall(FlutterKeychainPlugin.kt:323)
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200)
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at android.os.MessageQueue.next(MessageQueue.java:325)
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at android.os.Looper.loop(Looper.java:142)
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at android.app.ActivityThread.main(ActivityThread.java:6541)
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
E/MethodChannel#plugin.appmire.be/flutter_keychain(29852): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
D/ (29852): HostConnection::get() New Host Connection established 0x724a7ce36680, tid 29895
D/EGL_emulation(29852): eglMakeCurrent: 0x724a95fa1c80: ver 3 0 (tinfo 0x724a8c40d540)
I/flutter (29852): Caught error: PlatformException(error, Unsupported value: javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT, null)
It happens in the emulator normally after an app crash. I have to then clear the data from the app and login again to the application (which imports the data into the keychain again).
Any ideas?
Few plugins already added macOS support
url_launcher
shared_preferences
connectivity
path_provider
This plugin need support too
https://flutter.dev/desktop
Hi,
I'm running into a few of these exceptions using workmanager (spawns a background isolate to do work).
Can you provide an api endpoint to register the plugin under those circumstances ? Thanks !
Steps to reproduce:
It will build successful but report an runtime error: dyld[2683]: Symbol not found: _OBJC_CLASS_$_NSObject
.
// keys - get all keys
static Future<List<String>> keys() async =>
await _channel.invokeMethod('keys');
Throws Unhandled Exception: MissingPluginException(No implementation found for method keys on channel plugin.appmire.be/flutter_keychain)
Kotlin code:
when (call.method) {
"get" -> {
val encryptedValue: String? = preferences.getString(call.key(), null)
val value = encryptor.decrypt(encryptedValue)
result.success(value)
}
"put" -> {
val value = encryptor.encrypt(call.value())
preferences.edit().putString(call.key(), value).commit()
result.success(null)
}
"remove" -> {
preferences.edit().remove(call.key()).commit()
result.success(null)
}
"clear" -> {
preferences.edit().clear().commit()
result.success(null)
}
else -> result.notImplemented()
}
Either this is removed from both the lib
and documentation, or the implementation should be added for iOS and Android
Hello everyone!
After installation this package I can`t run application. I get error only for Android:
.../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_keychain-2.0.0/android/src/main/kotlin/be/appmire/flutterkeychain/FlutterKeychainPlugin.kt: (320, 39): Type mismatch: inferred type is String? but String was expected
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_keychain:compileDebugKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
Exception: Gradle task assembleDebug failed with exit code 1
My environment:
Android Studio 4.2.1
Flutter 2.2.0
Kotlin 202-1.5.0-release-764-AS8194.7
Any clues? Thanks!
@jeroentrappers
On some android devices, like the Samsung Galaxy S9, if you don't explicitly call commit, shared prefs will not be updated and it will be like you never deleted the key.
"remove" -> {
preferences.edit()
.remove(call.key())
.commit()
result.success(null)
}
"clear" -> {
preferences.edit()
.clear()
.commit()
result.success(null)
}
You may also want add @SuppressLint("ApplySharedPref")
to the method since android studio complains about using commit() over apply(). But in this case, I would think that commit (which synchronously) is the correct behaviour.
When I'm running the app this warning pops up:
The plugin flutter_keychain
uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Hi,
Can you help me understand how this package relates to mogol/flutter_secure_storage, the readme is surprisingly similar.
No implementation found for method put on channel plugin.appmire.be/flutter_keychain
HTC One (m7), Android 5.0
java.lang.NoClassDefFoundError:
at be.appmire.flutterkeychain.RsaKeyStoreKeyWrapper.createKeys (FlutterKeychainPlugin.kt:156)
at be.appmire.flutterkeychain.RsaKeyStoreKeyWrapper.createRSAKeysIfNeeded (FlutterKeychainPlugin.kt:123)
at be.appmire.flutterkeychain.RsaKeyStoreKeyWrapper.<init> (FlutterKeychainPlugin.kt:48)
at be.appmire.flutterkeychain.FlutterKeychainPlugin$Companion.registerWith (FlutterKeychainPlugin.kt:280)
at be.appmire.flutterkeychain.FlutterKeychainPlugin.registerWith (FlutterKeychainPlugin.kt)
at io.flutter.plugins.GeneratedPluginRegistrant.registerWith (GeneratedPluginRegistrant.java:26)
at com.nartus.mywallet.MainActivity.onCreate (MainActivity.java:11)
at android.app.Activity.performCreate (Activity.java:5958)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2474)
at android.app.ActivityThread.access$800 (ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1359)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:155)
at android.app.ActivityThread.main (ActivityThread.java:5696)
at java.lang.reflect.Method.invoke (Native Method)
at java.lang.reflect.Method.invoke (Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1028)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:823)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass (ClassLoader.java:511)
at java.lang.ClassLoader.loadClass (ClassLoader.java:469)
Sometimes on debug mode, and more often in release mode, the following occurs:
E/flutter_keychain(13452): error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): Failed to handle method call
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): java.lang.IllegalArgumentException: Unsupported value: javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:294)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at io.flutter.plugin.common.StandardMethodCodec.encodeErrorEnvelope(StandardMethodCodec.java:70)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:230)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at be.appmire.flutterkeychain.FlutterKeychainPlugin.onMethodCall(FlutterKeychainPlugin.kt:323)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:90)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:234)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at android.app.ActivityThread.main(ActivityThread.java:6940)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
E/MethodChannel#plugin.appmire.be/flutter_keychain(13452): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/flutter (13452): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Unsupported value: javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT, null)
when using the get
method
// get - get the value for a given key
static Future<String> get({@required String key}) async =>
await _channel.invokeMethod('get', {'key': key});
Any plans to support biometric authentication?
On iOS this can be implemented by sending the biometryAny
or biometryCurrentSet
SecAccessControlCreateFlags
, the system will then handle showing a TouchID/FaceID prompt to the user when the value is read back.
On Android this can be implemented with a .setUserAuthenticationRequired(true)
call together with BiometricPrompt
(using androidx for backwards compat). Here is an example from Google, and here is a guide on getting the compat lib up and running.
🚀
Where is the storage on the device or ???
iOS?
Android?
Thanks
With iOS you can restrict access to the keychain based upon the device state (passcode set, unlocked, after first unlock or always) which you have implemented.
You can also require the user presence - - Allowing access only when the device is unlocked (the default) may not be secure enough in all cases. If your app provides direct control over a bank account, you can check for the presence of the authorized user at the very last minute before retrieving login credentials from the keychain. This helps secure the account even if the user hands the device in an unlocked state to someone else.
Would it be possible to add this functionality to flutter_keychain?
https://developer.apple.com/documentation/security/keychain_services/keychain_items/restricting_keychain_item_accessibility under Demand User Presence.
Migrate the package with null safety support
Getting a weird message when building:
[10:24:26]: ▸ ⚠️ /Users/me/.fluttersdk/.pub-cache/hosted/pub.dartlang.org/flutter_keychain-1.0.0/ios/Classes/FlutterKeychainPlugin.m:95:49: values of type 'OSStatus' should not be used as format arguments; add an explicit cast to 'int' instead [-Wformat]
[10:24:26]: ▸ NSLog(@"SecItemUpdate status = %d", status);
[10:24:26]: ▸ ~~ ^~~~~~
[10:24:26]: ▸ ⚠️ /Users/me/.fluttersdk/.pub-cache/hosted/pub.dartlang.org/flutter_keychain-1.0.0/ios/Classes/FlutterKeychainPlugin.m:103:46: values of type 'OSStatus' should not be used as format arguments; add an explicit cast to 'int' instead [-Wformat]
[10:24:26]: ▸ NSLog(@"SecItemAdd status = %d", status);
[10:24:26]: ▸ ~~ ^~~~~~
Seems you can just cast it to (int) like they did in this project:
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.40 and higher.
The following dependencies do not satisfy the required version:
project ':flutter_keychain' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21
Hello! I made a package with flutter and imported it into swift project.
In my swift project, I can read data stored by flutter_keychain in flutter part. However, in flutter package, I can't read data from swift keychain. I tried other keychain package such as flutter_secure_storage. I got the same result.
What's more, in flutter project, I can't use flutter_secure_storage to read data stored by flutter_keychain.
Is there any way I can do to read data stored in swift project? Thanks a lot.
When using this library ion Android 9, the following occurs:
W/KeyStore( 1614): KeyStore exception
W/KeyStore( 1614): android.os.ServiceSpecificException: (code 7)
W/KeyStore( 1614): at android.os.Parcel.createException(Parcel.java:1964)
W/KeyStore( 1614): at android.os.Parcel.readException(Parcel.java:1918)
W/KeyStore( 1614): at android.os.Parcel.readException(Parcel.java:1868)
W/KeyStore( 1614): at android.security.IKeystoreService$Stub$Proxy.get(IKeystoreService.java:786)
W/KeyStore( 1614): at android.security.KeyStore.get(KeyStore.java:195)
W/KeyStore( 1614): at android.security.keystore.AndroidKeyStoreSpi.engineGetCertificateChain(AndroidKeyStoreSpi.java:118)
W/KeyStore( 1614): at java.security.KeyStoreSpi.engineGetEntry(KeyStoreSpi.java:484)
W/KeyStore( 1614): at java.security.KeyStore.getEntry(KeyStore.java:1560)
W/KeyStore( 1614): at be.appmire.flutterkeychain.RsaKeyStoreKeyWrapper.createRSAKeysIfNeeded(FlutterKeychainPlugin.kt:125)
W/KeyStore( 1614): at be.appmire.flutterkeychain.RsaKeyStoreKeyWrapper.<init>(FlutterKeychainPlugin.kt:48)
W/KeyStore( 1614): at be.appmire.flutterkeychain.FlutterKeychainPlugin$Companion.registerWith(FlutterKeychainPlugin.kt:280)
W/KeyStore( 1614): at be.appmire.flutterkeychain.FlutterKeychainPlugin.registerWith(Unknown Source:2)
W/KeyStore( 1614): at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:31)
W/KeyStore( 1614): at com.ianum.ianumflutter.MainActivity.onCreate(MainActivity.kt:12)
W/KeyStore( 1614): at android.app.Activity.performCreate(Activity.java:7155)
W/KeyStore( 1614): at android.app.Activity.performCreate(Activity.java:7146)
W/KeyStore( 1614): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288)
W/KeyStore( 1614): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3037)
W/KeyStore( 1614): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3197)
W/KeyStore( 1614): at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
W/KeyStore( 1614): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
W/KeyStore( 1614): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
W/KeyStore( 1614): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
W/KeyStore( 1614): at android.os.Handler.dispatchMessage(Handler.java:106)
W/KeyStore( 1614): at android.os.Looper.loop(Looper.java:193)
W/KeyStore( 1614): at android.app.ActivityThread.main(ActivityThread.java:6923)
W/KeyStore( 1614): at java.lang.reflect.Method.invoke(Native Method)
W/KeyStore( 1614): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
W/KeyStore( 1614): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
This may happen due to the fact that Android changed the way it accesses the Keychain: https://stackoverflow.com/a/52295484/4499889
Would it be available that keep the key stored by this plugin even if reinstall the app?
When I try building the apk, I got this issue.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':flutter_keychain:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
> Android resource linking failed
ERROR: /Users/mr.minnu/survey/build/flutter_keychain/intermediates/aapt_friendly_merged_manifests/release/aapt/AndroidManifest.xml:2: AAPT: error: attribute 'package' in <manifest> tag is not a valid Android package name: 'flutter_keychain'.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
* Get more help at https://help.gradle.org
Get this error for some of my Android users.
Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: PlatformException(flutter_keychain, error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT, 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 d0.a.b(Unknown Source:40)
at d0.b.onMethodCall(Unknown Source:181)
at v4.k$a.a(Unknown Source:17)
at i4.c.l(Unknown Source:18)
at i4.c.m(Unknown Source:40)
at i4.c.i(Unknown Source:0)
at i4.b.run(Unknown Source:12)
at android.os.Handler.handleCallback(Handler.java:978)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loopOnce(Looper.java:238)
at android.os.Looper.loop(Looper.java:355)
at android.app.ActivityThread.main(ActivityThread.java:8080)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1026)
, null). Error thrown PlatformException.
at StandardMethodCodec.decodeEnvelope(message_codecs.dart:653)
at MethodChannel._invokeMethod(platform_channel.dart:315)
at FlutterKeychain.get(flutter_keychain.dart:15)
at ._getHydratedStorageEncryptionKey(bootstrap.dart:421)
at ._getHydratedStorage(bootstrap.dart:409)
at .bootstrap(bootstrap.dart:40)
at .mainDelegate(main_delegate.dart:72)
This is the code
Future<Storage> _getHydratedStorage() async {
var encryptionKey = await _getHydratedStorageEncryptionKey();
final storage = await HydratedStorage.build(
storageDirectory: await getTemporaryDirectory(),
encryptionCipher: HydratedAesCipher(
sha256.convert(utf8.encode(encryptionKey)).bytes,
),
);
return storage;
}
Future<String> _getHydratedStorageEncryptionKey() async {
const storageKey = '...';
var encryptionKey = await FlutterKeychain.get(
key: storageKey,
);
if (encryptionKey == null) {
encryptionKey = base64.encode(Hive.generateSecureKey());
await FlutterKeychain.put(
key: storageKey,
value: encryptionKey,
);
}
return encryptionKey;
}
And this is the version of the package.
environment:
sdk: '>=2.19.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
flutter_keychain: ^2.2.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.