java.lang.Object
org.elasticsearch.common.ssl.PemUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic PrivateKeyparsePKCS8PemString(String pemString) Creates aPrivateKeyfrom a String that contains the PEM encoded representation of a plaintext private key encoded in PKCS8static List<Certificate> readCertificates(Collection<Path> certPaths) static PrivateKeyreadPrivateKey(Path path, Supplier<char[]> passwordSupplier) Creates aPrivateKeyfrom the contents of a file and handles any exceptions
-
Method Details
-
readPrivateKey
public static PrivateKey readPrivateKey(Path path, Supplier<char[]> passwordSupplier) throws IOException, GeneralSecurityException Creates aPrivateKeyfrom the contents of a file and handles any exceptions- Parameters:
path- the path for the key filepasswordSupplier- A password supplier for the potentially encrypted (password protected) key- Returns:
- a private key from the contents of the file
- Throws:
IOExceptionGeneralSecurityException
-
parsePKCS8PemString
public static PrivateKey parsePKCS8PemString(String pemString) throws IOException, GeneralSecurityException Creates aPrivateKeyfrom a String that contains the PEM encoded representation of a plaintext private key encoded in PKCS8- Parameters:
pemString- the PEM encoded representation of a plaintext private key encoded in PKCS8- Returns:
PrivateKey- Throws:
IOException- if the algorithm identifier can not be parsed from DERGeneralSecurityException- if the private key can't be generated from thePKCS8EncodedKeySpec
-
readCertificates
public static List<Certificate> readCertificates(Collection<Path> certPaths) throws CertificateException, IOException - Throws:
CertificateExceptionIOException
-