Class PemContent

java.lang.Object
org.springframework.boot.ssl.pem.PemContent

public final class PemContent extends Object
PEM encoded content that can provide certificates and private keys.
Since:
3.2.0
  • Method Details

    • getCertificates

      public List<X509Certificate> getCertificates()
      Parse and return all certificates from the PEM content. Most PEM files either contain a single certificate or a certificate chain.
      Returns:
      the certificates
      Throws:
      IllegalStateException - if no certificates could be loaded
    • getPrivateKey

      public PrivateKey getPrivateKey()
      Parse and return the private keys from the PEM content.
      Returns:
      the private keys
      Throws:
      IllegalStateException - if no private key could be loaded
    • getPrivateKey

      public PrivateKey getPrivateKey(String password)
      Parse and return the private keys from the PEM content or null if there is no private key.
      Parameters:
      password - the password to decrypt the private keys or null
      Returns:
      the private keys
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • load

      public static PemContent load(Path path) throws IOException
      Load PemContent from the given Path.
      Parameters:
      path - a path to load the content from
      Returns:
      the loaded PEM content
      Throws:
      IOException - on IO error
    • load

      public static PemContent load(InputStream in) throws IOException
      Load PemContent from the given InputStream.
      Parameters:
      in - an input stream to load the content from
      Returns:
      the loaded PEM content
      Throws:
      IOException - on IO error
    • of

      public static PemContent of(String text)
      Return a new PemContent instance containing the given text.
      Parameters:
      text - the text containing PEM encoded content
      Returns:
      a new PemContent instance
    • isPresentInText

      public static boolean isPresentInText(String text)
      Return if PEM content is present in the given text.
      Parameters:
      text - the text to check
      Returns:
      if the text includes PEM encoded content.