getPrivateKeyEntryFromP12Stream

fun getPrivateKeyEntryFromP12Stream(inputStream: InputStream, password: String? = null, alias: String? = null, keyPassword: String? = null): KeyStore.PrivateKeyEntry

Convenience method to load a certificate/private key pair from a PKCS#12 file (usually with .p12 extension).

Return

a java.security.KeyStore.PrivateKeyEntry representing the certificate/private key pair loaded from the keystore.

Parameters

inputStream

Input stream reading a p12 file.

password

Password for the keystore, may be null if keystore isn't password protected.

alias

Key pair alias (name) inside the keystore. If null, uses the first one found.

keyPassword

Password for the keypair inside the keystore, may be null if key isn't password protected.

Throws

if keystore can't be opened and read.

if key or keystore passwords don't match the ones in the actual file.