PEMFile (Apache Tomcat 10.1.55 API Documentation)
Description: declaration: package: org.apache.tomcat.util.net.jsse, class: PEMFile

# Class PEMFile

java.lang.Object
org.apache.tomcat.util.net.jsse.PEMFile

public class PEMFile extends Object
RFC 1421 PEM file containing X509 certificates or private keys.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PEMFile(String filename)`
  `PEMFile(String filename, InputStream fileStream, String password, String keyAlgorithm)`
  `PEMFile(String filename, InputStream fileStream, String password, String passwordFilename, InputStream passwordFileStream, String keyAlgorithm)`
  `PEMFile(String filename, String password)`
  `PEMFile(String filename, String password, String keyAlgorithm)`
  `PEMFile(String filename, String password, String passwordFilename, String keyAlgorithm)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `List<X509Certificate>`
  `getCertificates()`
  `PrivateKey`
  `getPrivateKey()`
  `static String`
  `toPEM(X509Certificate certificate)`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### PEMFile

    public PEMFile(String filename) throws IOException, GeneralSecurityException
    Throws:
      `IOException`
      `GeneralSecurityException`

  - ### PEMFile

    public PEMFile(String filename, String password) throws IOException, GeneralSecurityException
    Throws:
      `IOException`
      `GeneralSecurityException`

  - ### PEMFile

    public PEMFile(String filename, String password, String keyAlgorithm) throws IOException, GeneralSecurityException
    Throws:
      `IOException`
      `GeneralSecurityException`

  - ### PEMFile

    public PEMFile(String filename, String password, String passwordFilename, String keyAlgorithm) throws IOException, GeneralSecurityException
    Throws:
      `IOException`
      `GeneralSecurityException`

  - ### PEMFile

    public PEMFile(String filename, InputStream fileStream, String password, String keyAlgorithm) throws IOException, GeneralSecurityException
    Throws:
      `IOException`
      `GeneralSecurityException`

  - ### PEMFile

    public PEMFile(String filename, InputStream fileStream, String password, String passwordFilename, InputStream passwordFileStream, String keyAlgorithm) throws IOException, GeneralSecurityException
    Parameters:
      `filename` - the filename to mention in error messages, not used for anything else.
      `fileStream` - the stream containing the pem(s).
      `password` - password to load the pem objects.
      `passwordFilename` - the password filename to mention in error messages, not used for anything else.
      `passwordFileStream` - stream containing the password to load the pem objects.
      `keyAlgorithm` - the algorithm to help to know how to load the objects (guessed if null).
    Throws:
      `IOException` - if input can't be read.
      `GeneralSecurityException` - if input can't be parsed/loaded.

- ## Method Details

  - ### toPEM

    public static String toPEM(X509Certificate certificate) throws CertificateEncodingException
    Throws:
      `CertificateEncodingException`

  - ### getCertificates

    public List<X509Certificate> getCertificates()

  - ### getPrivateKey

    public PrivateKey getPrivateKey()