public class KeyUtil extends Object
| Constructor and Description |
|---|
KeyUtil() |
| Modifier and Type | Method and Description |
|---|---|
static File |
generatePKCS8FromPrivateKey(Path tmpDir,
char[] password,
PrivateKey key)
Build a password-encrypted PKCS8 private key and write it to a PEM file in the temp directory.
|
static KeyManager[] |
initKeyStore(File tlsKeyFile,
File tlsCertFile,
String tlsKeyPassword) |
static Collection<? extends Certificate> |
loadCertificates(Path certificatePath) |
protected static PrivateKey |
loadPrivateKey(File file,
String password) |
static X509Certificate[] |
loadX509Certificates(Path certificatePath) |
static PrivateKey |
privateKeyFromFile(String password,
File keyFile)
Obtain a private key from a PKS8 PEM file, which is optionally password-protected.
|
static X509Certificate |
readCertificate(Path path) |
static PrivateKey |
readPrivateKey(Path path) |
public static X509Certificate[] loadX509Certificates(Path certificatePath) throws CertificateException, IOException
CertificateExceptionIOExceptionpublic static Collection<? extends Certificate> loadCertificates(Path certificatePath) throws CertificateException, IOException
CertificateExceptionIOExceptionpublic static KeyManager[] initKeyStore(File tlsKeyFile, File tlsCertFile, String tlsKeyPassword) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionprotected static PrivateKey loadPrivateKey(File file, String password) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionpublic static X509Certificate readCertificate(Path path) throws IOException
IOExceptionpublic static PrivateKey readPrivateKey(Path path) throws IOException
IOExceptionpublic static File generatePKCS8FromPrivateKey(Path tmpDir, char[] password, PrivateKey key) throws GeneralSecurityException
tmpDir - path to directory in which to create thepassword - to protect the keykey - encrypt this keyGeneralSecurityExceptionpublic static PrivateKey privateKeyFromFile(String password, File keyFile) throws IOException, org.bouncycastle.pkcs.PKCSException, org.bouncycastle.operator.OperatorCreationException
password - password to decrypt the file - it may be null or empty in case of an unencrypted filekeyFile - the key fileIOExceptionorg.bouncycastle.pkcs.PKCSExceptionorg.bouncycastle.operator.OperatorCreationExceptionCopyright © 2012–2021 Graylog, Inc.. All rights reserved.