Class PEMDecoder
-
Method Summary
Modifier and TypeMethodDescriptionstatic X509Certificate[]
getCertificatePath
(byte[] pemBlob) Returns a javaX509Certificate
path.static KeyPair
getKeyPair
(byte[] pemBlob) Returns a javaKeyPair
.static KeyStore
getKeyStore
(byte[] pemBlob, String alias, String password) Returns a javaKeyStore
.static PrivateKey
getPrivateKey
(byte[] pemBlob) Returns a javaPrivateKey
.static PublicKey
getPublicKey
(byte[] pemBlob) Returns a javaPublicKey
.
-
Method Details
-
getKeyPair
Returns a javaKeyPair
.Note that this method presumes that there is one PRIVATE KEY present and that is in the extended PKCS #8 format that also holds the associated public key. The latter only applies to EC and OKP keys since public key is implicit for RSA private keys. However, if there is a PUBLIC KEY element as well, this takes precedence over public keys suppled in PKCS #8 extensions. ED25519 keys generated by OpenSSL seem to require such an arrangement.
- Parameters:
pemBlob
- PEM input- Returns:
- Key pair
- Throws:
CryptoException
-
getPrivateKey
Returns a javaPrivateKey
.Note that this method presumes that there is one PRIVATE KEY present and uses the PKCS #8 format.
- Parameters:
pemBlob
- PEM input- Returns:
- Private key
- Throws:
CryptoException
-
getPublicKey
Returns a javaPublicKey
.Note that this method presumes that there is one PUBLIC KEY present.
- Parameters:
pemBlob
- PEM input- Returns:
- Public key
- Throws:
CryptoException
-
getCertificatePath
Returns a javaX509Certificate
path.Note that this method presumes that there is one or more CERTIFICATE elements present. The certificates are checked for path conformance, including verifying that they are listed in the PEM file in ascending order.
- Parameters:
pemBlob
- PEM input- Returns:
- Certficate path
- Throws:
CryptoException
-
getKeyStore
Returns a javaKeyStore
.Note that this method depends on
getCertificatePath(byte[])
andgetPrivateKey(byte[])
.- Parameters:
pemBlob
- PEM input- Returns:
- Initialized KeyStore
- Throws:
CryptoException
-