Package org.graylog2.shared.security.tls
Class PemKeyStore
java.lang.Object
org.graylog2.shared.security.tls.PemKeyStore
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic KeyStore
buildKeyStore
(Path certChainFile, Path keyFile, char[] keyPasswordChars) Generates a newKeyStore
.protected static PKCS8EncodedKeySpec
generateKeySpec
(char[] password, byte[] key) Generates a key specification for an (encrypted) private key.
-
Constructor Details
-
PemKeyStore
public PemKeyStore()
-
-
Method Details
-
generateKeySpec
protected static PKCS8EncodedKeySpec generateKeySpec(char[] password, byte[] key) throws IOException, org.bouncycastle.pkcs.PKCSException, org.bouncycastle.operator.OperatorCreationException Generates a key specification for an (encrypted) private key.- Parameters:
password
- characters, ifnull
or empty an unencrypted key is assumedkey
- bytes of the DER encoded private key- Returns:
- a key specification
- Throws:
IOException
- if parsingkey
failsorg.bouncycastle.pkcs.PKCSException
- if the decryption key based onpassword
cannot be used to decryptkey
org.bouncycastle.operator.OperatorCreationException
- if the decryption algorithm parameters are somehow faulty
-
buildKeyStore
public static KeyStore buildKeyStore(Path certChainFile, Path keyFile, char[] keyPasswordChars) throws GeneralSecurityException Generates a newKeyStore
.- Parameters:
certChainFile
- a X.509 certificate chain file in PEM format,keyFile
- a PKCS#8 private key file in PEM format,keyPasswordChars
- the password of thekeyFile
.null
if it's not password-protected.- Returns:
- generated
KeyStore
. - Throws:
GeneralSecurityException
- on any error regarding key generation
-