Created
May 12, 2020 04:53
-
-
Save nilsmagnus/750432977ff3c938026ed1cd7323bba8 to your computer and use it in GitHub Desktop.
Get public key from android keystore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.security.KeyStore | |
import arrow.core.Option | |
const val SIGN_CERT_ALIAS = "SIGN" | |
fun getPublicSigningKey(): Option<PublicKey> = | |
runCatching { | |
val ks: KeyStore = KeyStore.getInstance("AndroidKeyStore").apply { | |
load(null) | |
} | |
ks.getCertificate(SIGN_CERT_ALIAS).publicKey | |
}.fold({ | |
Option.just(it) | |
}, { | |
Option.empty() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment