# Class PemReader

java.lang.Object
org.apache.zookeeper.util.PemReader

public final class PemReader extends Object
Note: this class is copied from io.airlift.security.pem.PemReader (see https://github.com/airlift/airlift/blob/master/security/src/main/java/io/airlift/security/pem/PemReader.java) with permission of the authors, to avoid adding an extra library dependency to Zookeeper. The file was copied from commit hash 86348546af43217f4d04a0cdad624b0ae4751c2c. The following modifications have been made to the original source code:

- imports have been rearranged to match Zookeeper import order style.
- The dependency on `com.google.common.io.Files.asCharSource` has been removed.
- A dependency on `java.nio.file.Files` has been added.

## Method Summary

Modifier and Type
Method
Description
`static KeyStore`
`loadKeyStore(File certificateChainFile, File privateKeyFile, Optional<String> keyPassword)`
`static PrivateKey`
`loadPrivateKey(File privateKeyFile, Optional<String> keyPassword)`
`static PrivateKey`
`loadPrivateKey(String privateKey, Optional<String> keyPassword)`
`static PublicKey`
`loadPublicKey(File publicKeyFile)`
`static PublicKey`
`loadPublicKey(String publicKey)`
`static KeyStore`
`loadTrustStore(File certificateChainFile)`
`static List<X509Certificate>`
`readCertificateChain(File certificateChainFile)`
`static List<X509Certificate>`
`readCertificateChain(String certificateChain)`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### loadTrustStore

public static KeyStore loadTrustStore(File certificateChainFile) throws IOException, GeneralSecurityException

Throws:
  `IOException`
  `GeneralSecurityException`

### loadKeyStore

public static KeyStore loadKeyStore(File certificateChainFile, File privateKeyFile, Optional<String> keyPassword) throws IOException, GeneralSecurityException

Throws:
  `IOException`
  `GeneralSecurityException`

### readCertificateChain

public static List<X509Certificate> readCertificateChain(File certificateChainFile) throws IOException, GeneralSecurityException

Throws:
  `IOException`
  `GeneralSecurityException`

### readCertificateChain

public static List<X509Certificate> readCertificateChain(String certificateChain) throws CertificateException

Throws:
  `CertificateException`

### loadPrivateKey

public static PrivateKey loadPrivateKey(File privateKeyFile, Optional<String> keyPassword) throws IOException, GeneralSecurityException

Throws:
  `IOException`
  `GeneralSecurityException`

### loadPrivateKey

public static PrivateKey loadPrivateKey(String privateKey, Optional<String> keyPassword) throws IOException, GeneralSecurityException

Throws:
  `IOException`
  `GeneralSecurityException`

### loadPublicKey

public static PublicKey loadPublicKey(File publicKeyFile) throws IOException, GeneralSecurityException

Throws:
  `IOException`
  `GeneralSecurityException`

### loadPublicKey

public static PublicKey loadPublicKey(String publicKey) throws GeneralSecurityException

Throws:
  `GeneralSecurityException`