public final class PEMReader
extends java.lang.Object
The input private key must be in PKCS#8 format.
It returns PKCS#8 formatted private key and X509 certificates.
Modifier and Type | Field and Description |
---|---|
static java.util.Set<java.lang.String> |
SUPPORTED_PRIVATE_KEY_ALGORITHMS
The private key can be with any of these algorithms in order for this read to successfully parse it.
|
Constructor and Description |
---|
PEMReader() |
Modifier and Type | Method and Description |
---|---|
static java.security.cert.Certificate[] |
extractCertificates(java.lang.String pemCerts)
Extracts the certificates/cert-chain from the PEM content.
|
static java.security.PrivateKey |
extractPrivateKey(java.lang.String unencryptedPEMKey)
Extracts private key from the PEM content for the private key, assuming its not PBE.
|
static java.security.PrivateKey |
extractPrivateKey(java.lang.String pemKey,
java.lang.String keyPassword)
Extracts private key from the Password Based Encrypted PEM content for the private key.
|
public static final java.util.Set<java.lang.String> SUPPORTED_PRIVATE_KEY_ALGORITHMS
RSA, DSA or ECThe first one to be evaluated is RSA, being the most common for private keys.
public static java.security.PrivateKey extractPrivateKey(java.lang.String unencryptedPEMKey) throws java.io.IOException, java.security.GeneralSecurityException
unencryptedPEMKey
- private key stored as PEM contentPrivateKey
upon successful reading of the private keyjava.io.IOException
- in case PEM reading failsjava.security.GeneralSecurityException
- in case any issue encountered while reading the private keypublic static java.security.PrivateKey extractPrivateKey(java.lang.String pemKey, java.lang.String keyPassword) throws java.io.IOException, java.security.GeneralSecurityException
pemKey
- PBE private key stored as PEM contentkeyPassword
- password to be used for the private key decryptionPrivateKey
upon successful reading of the private keyjava.io.IOException
- in case PEM reading failsjava.security.GeneralSecurityException
- in case any issue encountered while reading the private keypublic static java.security.cert.Certificate[] extractCertificates(java.lang.String pemCerts) throws java.security.GeneralSecurityException
pemCerts
- certificates/cert-chain stored as PEM contentjava.security.GeneralSecurityException
- in case any issue encountered while reading the certificatesCopyright © 2009- The Apache Software Foundation