Package nl.altindag.ssl.pem.util
Class PemUtils
java.lang.Object
nl.altindag.ssl.pem.util.PemUtils
Reads PEM formatted private keys and certificates
as identity material and trust material and maps it
to either a
The PemUtils provides also other methods for example to:
X509ExtendedKeyManager or X509ExtendedTrustManager.
The PemUtils provides also other methods for example to:
- load trusted certificates and map it into a list ofX509Certificate- load identity material and map it into aPrivateKey
The PemUtils serves mainly as a helper class to easily supply the PEM formatted SSL material
for the SSLFactory, but can also be used for other purposes.
- Author:
- Hakan Altindag
-
Method Summary
Modifier and TypeMethodDescriptionstatic PublicKeyextractPublicKey(PrivateKey privateKey) static List<X509Certificate>loadCertificate(InputStream... certificateStreams) Loads certificates from multiple InputStreams and maps it to a list ofX509Certificatestatic List<X509Certificate>loadCertificate(String... certificatePaths) Loads certificates from the classpath and maps it to a list ofX509Certificatestatic List<X509Certificate>loadCertificate(Path... certificatePaths) Loads certificates from the filesystem and maps it to a list ofX509Certificatestatic X509ExtendedKeyManagerloadIdentityMaterial(InputStream identityStream) Loads the identity material based on a combined entity containing the certificate chain and the private key from an InputStream and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(InputStream identityStream, char[] keyPassword) Loads the identity material based on a combined entity containing the certificate chain and the private key from an InputStream and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(InputStream certificateChainStream, InputStream privateKeyStream) Loads the identity material based on a certificate chain and a private key as an InputStream and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(InputStream certificateChainStream, InputStream privateKeyStream, char[] keyPassword) Loads the identity material based on a certificate chain and a private key as an InputStream and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(String identityPath) Loads the identity material based on a combined file containing the certificate chain and the private key from the classpath and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(String identityPath, char[] keyPassword) Loads the identity material based on a combined file containing the certificate chain and the private key from the classpath and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(String certificateChainPath, String privateKeyPath) Loads the identity material based on a certificate chain and a private key from the classpath and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(String certificateChainPath, String privateKeyPath, char[] keyPassword) Loads the identity material based on a certificate chain and a private key from the classpath and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(Path identityPath) Loads the identity material based on a combined file containing the certificate chain and the private key from the filesystem and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(Path identityPath, char[] keyPassword) Loads the identity material based on a combined file containing the certificate chain and the private key from the filesystem and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(Path certificateChainPath, Path privateKeyPath) Loads the identity material based on a certificate chain and a private key from the filesystem and maps it to an instance ofX509ExtendedKeyManagerstatic X509ExtendedKeyManagerloadIdentityMaterial(Path certificateChainPath, Path privateKeyPath, char[] keyPassword) Loads the identity material based on a certificate chain and a private key from the filesystem and maps it to an instance ofX509ExtendedKeyManagerstatic PrivateKeyloadPrivateKey(InputStream identityStream) Loads the private key from an InputStream and maps it to an instance ofPrivateKeystatic PrivateKeyloadPrivateKey(InputStream identityStream, char[] keyPassword) Loads the private key from an InputStream and maps it to an instance ofPrivateKeystatic PrivateKeyloadPrivateKey(String identityPath) Loads the private key from the classpath and maps it to an instance ofPrivateKeystatic PrivateKeyloadPrivateKey(String identityPath, char[] keyPassword) Loads the private key from the classpath and maps it to an instance ofPrivateKeystatic PrivateKeyloadPrivateKey(Path identityPath) Loads the private key from the filesystem and maps it to an instance ofPrivateKeystatic PrivateKeyloadPrivateKey(Path identityPath, char[] keyPassword) Loads the private key from the filesystem and maps it to an instance ofPrivateKeystatic X509ExtendedTrustManagerloadTrustMaterial(InputStream... certificateStreams) Loads certificates from multiple InputStreams and maps it to an instance ofX509ExtendedTrustManagerstatic X509ExtendedTrustManagerloadTrustMaterial(String... certificatePaths) Loads certificates from the classpath and maps it to an instance ofX509ExtendedTrustManagerstatic X509ExtendedTrustManagerloadTrustMaterial(Path... certificatePaths) Loads certificates from the filesystem and maps it to an instance ofX509ExtendedTrustManagerstatic List<X509Certificate>parseCertificate(String certContent) static X509ExtendedKeyManagerparseIdentityMaterial(String identityContent) Parses the identity material based on a string representation containing the certificate chain and the private key and maps it to an instance ofX509ExtendedTrustManagerstatic X509ExtendedKeyManagerparseIdentityMaterial(String identityContent, char[] keyPassword) Parses the identity material based on a string representation containing the certificate chain and the private key and maps it to an instance ofX509ExtendedTrustManagerstatic X509ExtendedKeyManagerparseIdentityMaterial(String certificateChainContent, String privateKeyContent, char[] keyPassword) Parses the identity material based on a string representation of the certificate chain and the private key and maps it to an instance ofX509ExtendedTrustManagerstatic PrivateKeyparsePrivateKey(String identityContent) Parses the private key based on a string representation of the private key and maps it to an instance ofPrivateKeystatic PrivateKeyparsePrivateKey(String identityContent, char[] keyPassword) Parses the private key based on a string representation of the private key and maps it to an instance ofPrivateKey.static X509ExtendedTrustManagerparseTrustMaterial(String... certificateContents) Parses one or more certificates as a string representation and maps it to an instance ofX509ExtendedTrustManager
-
Method Details
-
loadTrustMaterial
Loads certificates from the classpath and maps it to an instance ofX509ExtendedTrustManager -
loadTrustMaterial
Loads certificates from the filesystem and maps it to an instance ofX509ExtendedTrustManager -
loadTrustMaterial
Loads certificates from multiple InputStreams and maps it to an instance ofX509ExtendedTrustManager -
loadCertificate
Loads certificates from the classpath and maps it to a list ofX509Certificate -
loadCertificate
Loads certificates from the filesystem and maps it to a list ofX509Certificate -
loadCertificate
Loads certificates from multiple InputStreams and maps it to a list ofX509Certificate -
parseCertificate
-
parseTrustMaterial
Parses one or more certificates as a string representation and maps it to an instance ofX509ExtendedTrustManager -
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(String certificateChainPath, String privateKeyPath) Loads the identity material based on a certificate chain and a private key from the classpath and maps it to an instance ofX509ExtendedKeyManager -
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(String certificateChainPath, String privateKeyPath, char[] keyPassword) Loads the identity material based on a certificate chain and a private key from the classpath and maps it to an instance ofX509ExtendedKeyManager -
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(InputStream certificateChainStream, InputStream privateKeyStream) Loads the identity material based on a certificate chain and a private key as an InputStream and maps it to an instance ofX509ExtendedKeyManager -
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(InputStream certificateChainStream, InputStream privateKeyStream, char[] keyPassword) Loads the identity material based on a certificate chain and a private key as an InputStream and maps it to an instance ofX509ExtendedKeyManager -
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(Path certificateChainPath, Path privateKeyPath) Loads the identity material based on a certificate chain and a private key from the filesystem and maps it to an instance ofX509ExtendedKeyManager -
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(Path certificateChainPath, Path privateKeyPath, char[] keyPassword) Loads the identity material based on a certificate chain and a private key from the filesystem and maps it to an instance ofX509ExtendedKeyManager -
loadIdentityMaterial
Loads the identity material based on a combined file containing the certificate chain and the private key from the classpath and maps it to an instance ofX509ExtendedKeyManager -
loadIdentityMaterial
Loads the identity material based on a combined file containing the certificate chain and the private key from the classpath and maps it to an instance ofX509ExtendedKeyManager -
loadIdentityMaterial
Loads the identity material based on a combined file containing the certificate chain and the private key from the filesystem and maps it to an instance ofX509ExtendedKeyManager -
loadIdentityMaterial
Loads the identity material based on a combined file containing the certificate chain and the private key from the filesystem and maps it to an instance ofX509ExtendedKeyManager -
loadIdentityMaterial
Loads the identity material based on a combined entity containing the certificate chain and the private key from an InputStream and maps it to an instance ofX509ExtendedKeyManager -
loadIdentityMaterial
public static X509ExtendedKeyManager loadIdentityMaterial(InputStream identityStream, char[] keyPassword) Loads the identity material based on a combined entity containing the certificate chain and the private key from an InputStream and maps it to an instance ofX509ExtendedKeyManager -
parseIdentityMaterial
Parses the identity material based on a string representation containing the certificate chain and the private key and maps it to an instance ofX509ExtendedTrustManager -
parseIdentityMaterial
public static X509ExtendedKeyManager parseIdentityMaterial(String identityContent, char[] keyPassword) Parses the identity material based on a string representation containing the certificate chain and the private key and maps it to an instance ofX509ExtendedTrustManager -
parseIdentityMaterial
public static X509ExtendedKeyManager parseIdentityMaterial(String certificateChainContent, String privateKeyContent, char[] keyPassword) Parses the identity material based on a string representation of the certificate chain and the private key and maps it to an instance ofX509ExtendedTrustManager -
loadPrivateKey
Loads the private key from the classpath and maps it to an instance ofPrivateKey -
loadPrivateKey
Loads the private key from the classpath and maps it to an instance ofPrivateKey -
loadPrivateKey
Loads the private key from the filesystem and maps it to an instance ofPrivateKey -
loadPrivateKey
Loads the private key from the filesystem and maps it to an instance ofPrivateKey -
loadPrivateKey
Loads the private key from an InputStream and maps it to an instance ofPrivateKey -
loadPrivateKey
Loads the private key from an InputStream and maps it to an instance ofPrivateKey -
parsePrivateKey
Parses the private key based on a string representation of the private key and maps it to an instance ofPrivateKey -
parsePrivateKey
Parses the private key based on a string representation of the private key and maps it to an instance ofPrivateKey. If the identity content contains multiple private keys it will use only the first one. -
extractPublicKey
-