SecureStorage icon indicating copy to clipboard operation
SecureStorage copied to clipboard

Can't retrieve values on Android Simulator

Open bzatrok opened this issue 5 years ago • 1 comments

Getting an UnrecoverableKeyException when trying to retrieve values from CrossSecureStorage on Xamarin Android. Issue doesn't happen on iOS.

I've seen it happen on android API level 25 and 27. A reinstall of the app is usually needed to fix the issue.

Here's a stacktrace:

{Java.Security.UnrecoverableKeyException: Failed to obtain information about key ---> Java.Lang.Exception: -32
   --- End of inner exception stack trace ---
  at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <3beddfcb1eb547cd8ce47c3097f6eaeb>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0001f] in <3beddfcb1eb547cd8ce47c3097f6eaeb>:0 
  at Java.Security.KeyStore.GetKey (System.String alias, System.Char[] password) [0x00043] in <ff9f3f3d4e134974a889db1b532c9b6e>:0 
  at Plugin.SecureStorage.AndroidKeyStoreImplementation+AndroidKeyStore.GetSymmetricKey () [0x00000] in <32517fff446a4abfbff8b506c1031d3c>:0 
  at Plugin.SecureStorage.AndroidKeyStoreImplementation+AndroidKeyStore.GetKey () [0x0000a] in <32517fff446a4abfbff8b506c1031d3c>:0 
  at Plugin.SecureStorage.AndroidKeyStoreImplementation+AndroidKeyStore.Decrypt (System.Byte[] data) [0x00009] in <32517fff446a4abfbff8b506c1031d3c>:0 
  at Plugin.SecureStorage.AndroidKeyStoreImplementation.GetValue (System.String key, System.String defaultValue) [0x0004e] in <32517fff446a4abfbff8b506c1031d3c>:0 
  at Plugin.SecureStorage.SecureStorageImplementation.GetValue (System.String key, System.String defaultValue) [0x00009] in <32517fff446a4abfbff8b506c1031d3c>:0 
  at App.Helpers.CartManager.get_CurrentCart () [0x00002] in /Path/to/File.cs:44 
  --- End of managed Java.Security.UnrecoverableKeyException stack trace ---
java.security.UnrecoverableKeyException: Failed to obtain information about key
	at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStoreSecretKeyFromKeystore(AndroidKeyStoreProvider.java:282)
	at android.security.keystore.AndroidKeyStoreSpi.engineGetKey(AndroidKeyStoreSpi.java:98)
	at java.security.KeyStore.getKey(KeyStore.java:1062)
	at md59d55c6560de094c7795e9ae0086e7c33.HomeActivity.n_onCreate(Native Method)
	at md59d55c6560de094c7795e9ae0086e7c33.HomeActivity.onCreate(HomeActivity.java:32)
	at android.app.Activity.performCreate(Activity.java:7009)
	at android.app.Activity.performCreate(Activity.java:7000)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
	at android.app.ActivityThread.-wrap11(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6494)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.security.KeyStoreException: -32
	at android.security.KeyStore.getKeyStoreException(KeyStore.java:697)
	at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStoreSecretKeyFromKeystore(AndroidKeyStoreProvider.java:283)
	... 17 more
}

bzatrok avatar Jul 18 '19 14:07 bzatrok