adorsys / secure-storage-android

Store strings & credentials securely encrypted on your device
Apache License 2.0
367 stars 58 forks source link

could not generate key in keystore on some devices #7

Closed MotassemJa closed 7 years ago

MotassemJa commented 7 years ago

I'm getting this error on a device with Android 4.4.2

Fatal Exception: java.lang.IllegalStateException: could not generate key in keystore
       at android.security.AndroidKeyPairGenerator.generateKeyPair(AndroidKeyPairGenerator.java:100)
       at java.security.KeyPairGenerator$KeyPairGeneratorImpl.generateKeyPair(KeyPairGenerator.java:275)
       at de.adorsys.android.securestoragelibrary.a.f(Unknown Source)
       at de.adorsys.android.securestoragelibrary.a.a(Unknown Source)
       at de.adorsys.android.securestoragelibrary.SecurePreferences.setValue(Unknown Source)
luckyhandler commented 7 years ago

issue is described here as well https://stackoverflow.com/q/31079543

luckyhandler commented 7 years ago

and here is probably a solution: https://stackoverflow.com/a/40447483/3734116. I will try to fix it as soon as possible.

MotassemJa commented 7 years ago

Thank you!

luckyhandler commented 7 years ago

Unfortunately, this is an open issue for the Android keystore itself: https://issuetracker.google.com/issues/37051017. So it cannot be fixed in this library. I will think about a solution how to handle the exception better than we do it right now...

luckyhandler commented 7 years ago

I close this issue as not related to our code...

luckyhandler commented 7 years ago

Hi MotassemJa,

I just added error handling to our library which at least let's you react to the issue. It's still on develop, so as soon as we merge to master and build a release you can catch the exception and display a message to the user that his/her device is not supported due to a key store issue.