public final class KeyFormatPem extends Object implements KeyFormat<String>
openssl pkcs8 -nocrypt -in pkcs8key.pem -out pkcs1key.pem
Private keys can be encrypted during export. This will produce a PKCS#8 EncryptedPrivateKeyInfo format PEM, using strong encryption parameters:
openssl pkcs8 -v2 aes-128-cbc -inform PEM -in in.pem -out out.pem
Modifier and Type | Field and Description |
---|---|
static KeyFormatPem |
WITH_CERTIFICATE
Exports the key material with the certificate as well.
|
static KeyFormatPem |
WITHOUT_CERTIFICATE
Exports the key material without any associated certificate.
|
Constructor and Description |
---|
KeyFormatPem(boolean includeCertificate)
Constructs a new PEM key format that does not encrypt private keys.
|
KeyFormatPem(boolean includeCertificate,
SecretReference<GenericSecret> encryptionPassword)
Constructs a new PEM key format that encrypts private keys using the given password.
|
Modifier and Type | Method and Description |
---|---|
String |
export(CryptoKey key,
Key rawKey)
Exports the given crypto key and raw key material.
|
KeyFormatPem |
withEncryptionPassword(SecretReference<GenericSecret> encryptionPassword)
Returns a new PEM key format that will encrypt private keys with the given password.
|
public static final KeyFormatPem WITHOUT_CERTIFICATE
public static final KeyFormatPem WITH_CERTIFICATE
public KeyFormatPem(boolean includeCertificate, SecretReference<GenericSecret> encryptionPassword)
includeCertificate
- whether to include any certificate associated with the key in the PEM.encryptionPassword
- the password to use for encrypting the private key.public KeyFormatPem(boolean includeCertificate)
includeCertificate
- whether to include any certificate associated with the key in the PEM.public KeyFormatPem withEncryptionPassword(SecretReference<GenericSecret> encryptionPassword)
encryptionPassword
- the encryption password.public String export(CryptoKey key, Key rawKey) throws NoSuchSecretException
KeyFormat
export
in interface KeyFormat<String>
key
- the crypto key.rawKey
- the raw key material.NoSuchSecretException
- if the secret could not be exported.Copyright © 2010-2018, ForgeRock All Rights Reserved.