Class X509PEMFileReader

java.lang.Object
com.unboundid.util.ssl.cert.X509PEMFileReader
All Implemented Interfaces:
Closeable, AutoCloseable

@ThreadSafety(level=NOT_THREADSAFE) public final class X509PEMFileReader extends Object implements Closeable
This class provides a mechanism for reading PEM-encoded X.509 certificates from a specified file. The PEM file may contain zero or more certificates. Each certificate should consist of the following:
  • A line containing only the string "-----BEGIN CERTIFICATE-----".
  • One or more lines representing the base64-encoded representation of the bytes that comprise the X.509 certificate.
  • A line containing only the string "-----END CERTIFICATE-----".


Any spaces that appear at the beginning or end of each line will be ignored. Empty lines and lines that start with the octothorpe (#) character will also be ignored.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The header string that should appear on a line by itself before the base64-encoded representation of the bytes that comprise an X.509 certificate.
    static final String
    The footer string that should appear on a line by itself after the base64-encoded representation of the bytes that comprise an X.509 certificate.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new X.509 PEM file reader that will read certificate information from the specified file.
    Creates a new X.509 PEM file reader that will read certificate information from the provided input stream.
    Creates a new X.509 PEM file reader that will read certificate information from the specified file.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes this X.509 PEM file reader.
    Reads the next certificate from the PEM file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • X509PEMFileReader

      public X509PEMFileReader(@NotNull String pemFilePath) throws IOException
      Creates a new X.509 PEM file reader that will read certificate information from the specified file.
      Parameters:
      pemFilePath - The path to the PEM file from which the certificates should be read. This must not be null and the file must exist.
      Throws:
      IOException - If a problem occurs while attempting to open the file for reading.
    • X509PEMFileReader

      public X509PEMFileReader(@NotNull File pemFile) throws IOException
      Creates a new X.509 PEM file reader that will read certificate information from the specified file.
      Parameters:
      pemFile - The PEM file from which the certificates should be read. This must not be null and the file must exist.
      Throws:
      IOException - If a problem occurs while attempting to open the file for reading.
    • X509PEMFileReader

      public X509PEMFileReader(@NotNull InputStream inputStream)
      Creates a new X.509 PEM file reader that will read certificate information from the provided input stream.
      Parameters:
      inputStream - The input stream from which the certificates should be read. This must not be null and it must be open for reading.
  • Method Details