ophio / secure-preferences

Android secure shared preferences using Android Keystore system
https://medium.com/@vashisthg/android-secure-shared-preferences-10f8356a4c2b
Apache License 2.0
348 stars 56 forks source link

Issue with KeyStore on android 9 #29

Open AtibaBryan opened 5 years ago

AtibaBryan commented 5 years ago

Hello, I added this library to my application and I've seen some issues where an android-9 phones occasionally have a problem loading or generating the key pair.

I've been digging around the android keystore code but I am a complete neophyte in this part of the stack so I was hoping that someone here could point me in the right direction.

I also think it may help if there really is a bug as I imagine many of us support android 9. I'm pasting a stack trace below.

Thanks for such a useful tool!

Caused by java.lang.NullPointerException: invalid null input
       at java.security.KeyStore$PrivateKeyEntry.(KeyStore.java:559)
       at java.security.KeyStore$PrivateKeyEntry.(KeyStore.java:526)
       at java.security.KeyStoreSpi.engineGetEntry(KeyStoreSpi.java:527)
       at java.security.KeyStore.getEntry(KeyStore.java:1621)
       at in.co.ophio.secure.vault.SecretKeyWrapper.(SecretKeyWrapper.java:66)
       at in.co.ophio.secure.core.KeyStoreKeyGenerator.loadOrGenerateKeys(KeyStoreKeyGenerator.java:66)
       at in.co.ophio.secure.core.KeyStoreKeyGenerator.(Unknown Source:1046)
       at in.co.ophio.secure.core.KeyStoreKeyGenerator.get(KeyStoreKeyGenerator.java:56)
       at com.myapp.app.utilities.Preferences.(Preferences.java:46)
       at com.myapp.app.core.AppApplication.onCreate(AppApplication.java:68)
       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6217)
       at android.app.ActivityThread.access$1200(ActivityThread.java:237)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1785)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7045)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)