1

This is my code:

val oldAlias = "oldAlias"
val newAlias = "newAlias"

if (keyStore.containsAlias(oldAlias) && keyStore.containsAlias(newAlias)) {
    try {
        deleteKeyStore(oldAlias)
        val newEntry: KeyStore.Entry = keyStore.getEntry(newAlias, null)
        keyStore.setEntry(oldAlias, newEntry, protParam = null) // exception is thrown here
        deleteKeyStore(newAlias)
    } catch (e: Exception) {
        Timber.e(e)
    }
}

I've tried running the method with and without deleting the oldAlias before calling the setEntry() method, but it doesn't help. In both cases, if I don't delete the old alias or don't delete it, the method throws this exception:

KeyStoreException: Can only replace keys with the same alias: oldName != newName in the same target domain: 0 != 0

How can I replace the value by key in KeyStore?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.