Class CertificateChain

java.lang.Object
org.mozilla.jss.netscape.security.x509.CertificateChain
All Implemented Interfaces:
Serializable

public class CertificateChain extends Object implements Serializable
See Also:
  • Field Details

  • Constructor Details

    • CertificateChain

      public CertificateChain()
      Constructs an empty certificate chain.
    • CertificateChain

      public CertificateChain(X509Certificate cert)
      constructs a certificate chain from a certificate.
      Parameters:
      cert - a certificate
    • CertificateChain

      public CertificateChain(X509Certificate[] certs)
      constructs a certificate chain from a X509 certificate array.
      Parameters:
      certs - a certificate array.
  • Method Details

    • getCertificates

      public List<X509Certificate> getCertificates()
      Returns the certificate list.
      Returns:
      The certificate list.
    • getCertificate

      public X509Certificate getCertificate(int index)
      returns the certificate at specified index in chain.
      Parameters:
      index - the index.
      Returns:
      the X509 certificate at the given index.
    • getFirstCertificate

      public X509Certificate getFirstCertificate()
      returns the first certificate in chain.
      Returns:
      the X509 certificate at the given index.
    • getChain

      public X509Certificate[] getChain()
      returns the certificate chain as an array of X509 certificates.
      Returns:
      an array of X509 Certificates.
    • sort

      public void sort() throws Exception
      Sorts certificate chain from root to leaf.
      Throws:
      Exception
    • encode

      public void encode(OutputStream out) throws IOException
      Throws:
      IOException
    • encode

      public void encode(OutputStream out, boolean sort) throws IOException
      encode in PKCS7 blob.
      Throws:
      IOException
    • decode

      public void decode(InputStream in) throws IOException
      decode from PKCS7 blob.
      Throws:
      IOException
    • writeObject

      private void writeObject(ObjectOutputStream out) throws IOException
      for serialization
      Throws:
      IOException
    • readObject

      private void readObject(ObjectInputStream in) throws IOException
      for serialization
      Throws:
      IOException
    • addCertificate

      public void addCertificate(X509Certificate cert)
    • addCertificateChain

      public void addCertificateChain(CertificateChain certChain)
    • addPKCS7

      public void addPKCS7(PKCS7 pkcs7)
    • fromPEMString

      public static CertificateChain fromPEMString(String input) throws Exception
      Convert a series of PEM certificates or a PKCS #7 data into a certificate chain. This method will only accept a single chain, so it cannot be used to load CA bundle.
      Throws:
      Exception
    • toPEMString

      public String toPEMString() throws Exception
      Convert the certificate chain into a series of PEM certificates.
      Throws:
      Exception
    • toPKCS7

      public PKCS7 toPKCS7() throws Exception
      Convert the certificate chain into a PKCS #7 object.
      Throws:
      Exception
    • toString

      public String toString()
      Converts the certificate chain to a readable string.
      Overrides:
      toString in class Object