Class KeyFileHelpersKt
-
- All Implemented Interfaces:
public final class KeyFileHelpersKt
-
-
Method Summary
Modifier and Type Method Description final static KeyStore.PrivateKeyEntry
getPrivateKeyEntryFromP12Stream(InputStream inputStream, String password, String alias, String keyPassword)
Convenience method to load a certificate/private key pair from a PKCS#12 file (usually with .p12 extension). final static PrivateKey
getPrivateKeyFromPemFile(InputStream inputStream)
Takes an input stream containing a PEM encoded private key and returns a PrivateKey instance. final static X509Certificate
loadCertificateFromFile(File file)
Convenience method to load a X. final static X509Certificate
loadCertificateFromStream(InputStream inputStream)
Convenience method to load a X. final static List<X509Certificate>
getX509Certificates(KeyStore.PrivateKeyEntry $self)
getX509Certificates fetches the certificateChain and if its null it fetches certificate from the KeyStore.PrivateKeyEntry checks if they are X509Certificate and returns all in a list -
-
Method Detail
-
getPrivateKeyEntryFromP12Stream
final static KeyStore.PrivateKeyEntry getPrivateKeyEntryFromP12Stream(InputStream inputStream, String password, String alias, String keyPassword)
Convenience method to load a certificate/private key pair from a PKCS#12 file (usually with .p12 extension).
- Parameters:
inputStream
- Input stream reading a p12 file.password
- Password for the keystore, may benull
if keystore isn't password protected.alias
- Key pair alias (name) inside the keystore.keyPassword
- Password for the keypair inside the keystore, may benull
if key isn't password protected.- Returns:
a java.security.KeyStore.PrivateKeyEntry representing the certificate/private key pair loaded from the keystore.
-
getPrivateKeyFromPemFile
final static PrivateKey getPrivateKeyFromPemFile(InputStream inputStream)
Takes an input stream containing a PEM encoded private key and returns a PrivateKey instance.
-
loadCertificateFromFile
final static X509Certificate loadCertificateFromFile(File file)
Convenience method to load a X.509 certificate from a File.
- Parameters:
file
- File containing certificate in PKCS#7 format.- Returns:
A X509Certificate instance if the certificate is loaded.
-
loadCertificateFromStream
final static X509Certificate loadCertificateFromStream(InputStream inputStream)
Convenience method to load a X.509 certificate from an InputStream.
- Parameters:
inputStream
- Input stream containing certificate in PKCS#7 format.- Returns:
A X509Certificate instance if the certificate is loaded.
-
getX509Certificates
final static List<X509Certificate> getX509Certificates(KeyStore.PrivateKeyEntry $self)
getX509Certificates fetches the certificateChain and if its null it fetches certificate from the KeyStore.PrivateKeyEntry checks if they are X509Certificate and returns all in a list
- Returns:
list of X509Certificate certificates
-
-
-
-