Is there a way of generating CSRs of keys stored inside an Android KeyStore? I know you can generate keys then generate a CSR and lastly store the keys inside the Android KeyStore, but is it also possible to generate CSRs of at an earlier point generated and already inside the KeyStore stored keys?
I tried to do it just the same way you would do it with freshly generated keys using Spongycastle. But i ran into a problem while creating the JCAContentSigner. Running this code:
new JcaContentSignerBuilder("SHA256WithRSAEncryption").setProvider("SC").build(privateKey)
It will throw the exception:
org.spongycastle.operator.OperatorCreationException: cannot create signer: Supplied key (android.security.keystore.AndroidKeyStoreRSAPrivateKey) is not a RSAPrivateKey instance
Without setting SpongyCastle as Security Provider, i get this exception:
org.spongycastle.operator.OperatorCreationException: cannot create signer: Keystore operation failed
So my question is, whether one of these three options is possible:
cast a android.security.keystore.AndroidKeyStoreRSAPrivateKey into a RSAPrivateKey instance?
get it to work without setting SpongyCastle as Security Provider?
generating a CSR without SpongyCastle?