I'm using a SharedPreferenceVault in my app and I received some NPE from some of my users (although very rarely) with the following stack trace:
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.security.KeyStore.contains(java.lang.String)' on a null object reference
at android.security.AndroidKeyStore.isKeyEntry(AndroidKeyStore.java:435)
at android.security.AndroidKeyStore.engineDeleteEntry(AndroidKeyStore.java:375)
at java.security.KeyStore.deleteEntry(KeyStore.java:410)
at com.bottlerocketstudios.vault.keys.wrapper.AndroidKeystoreSecretKeyWrapper.clearKey(AndroidKeystoreSecretKeyWrapper.java:156)
at com.bottlerocketstudios.vault.keys.storage.SharedPrefKeyStorage.clearKey(SharedPrefKeyStorage.java:83)
at com.bottlerocketstudios.vault.StandardSharedPreferenceVault.clearStorage(StandardSharedPreferenceVault.java:320)
at com.bottlerocketstudios.vault.StandardSharedPreferenceVault.rekeyStorage(StandardSharedPreferenceVault.java:325)
at com.bottlerocketstudios.vault.SharedPreferenceVaultFactory.getAppKeyedCompatAes256Vault(SharedPreferenceVaultFactory.java:96)
at com.bottlerocketstudios.vault.SharedPreferenceVaultFactory.getAppKeyedCompatAes256Vault(SharedPreferenceVaultFactory.java:105)
and in my code I used the SharedPreferenceVault as bellow:
mVault = SharedPreferenceVaultFactory.getAppKeyedCompatAes256Vault(
context,
PREF_FILE_NAME, //Preference file name to store content
KEY_FILE_NAME, //Preference file to store key material
KEY_ALIAS, //App-wide unique key alias
VAULT_ID, //App-wide unique vault id
secret //Random string for pre v18
);
As I mentioned it above, this issue is occurred rarely and only in android 5.0.2.
If you have any clue of what is going wrong I would be very thankful.
I'm using a SharedPreferenceVault in my app and I received some NPE from some of my users (although very rarely) with the following stack trace:
and in my code I used the SharedPreferenceVault as bellow:
As I mentioned it above, this issue is occurred rarely and only in android 5.0.2.
If you have any clue of what is going wrong I would be very thankful.