Search code examples
androidsecuritykeystore

Android Keystore Type which one should I choose?


I want to store secure data in a keystore. Therefore I use

KeyStore store = KeyStore.getInstance("JCEKS");

But Android seems to not know "JCEKS".

04-18 10:52:17.236: WARN/System.err(474): java.security.KeyStoreException: KeyStore JCEKS implementation not found

Trying JKS gives the same error. What algorithm is good to use it on android?


Solution

  • Android seems to be using bouncycastle provider. This is the default provider that, the api returns. To be sure which one is available as default on the device use KeyStore.getDefaultType().

    In my case this returned 'BKS'. Also there seems to be an exception when there is a '.' character in the keystore file path.

    when I stored the store to a folder with the name of my package (as recommended in the Android documentation), it resulted in an exception.

    you may like to check this also.