Package org.graylog2.shared.security.tls
Class PemKeyStore
java.lang.Object
org.graylog2.shared.security.tls.PemKeyStore
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic KeyStorebuildKeyStore(Path certChainFile, Path keyFile, char[] keyPasswordChars) Generates a newKeyStore.protected static PKCS8EncodedKeySpecgenerateKeySpec(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, ifnullor empty an unencrypted key is assumedkey- bytes of the DER encoded private key- Returns:
- a key specification
- Throws:
IOException- if parsingkeyfailsorg.bouncycastle.pkcs.PKCSException- if the decryption key based onpasswordcannot be used to decryptkeyorg.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.nullif it's not password-protected.- Returns:
- generated
KeyStore. - Throws:
GeneralSecurityException- on any error regarding key generation
-