Package org.bouncycastle.tls
Class Certificate
- java.lang.Object
-
- org.bouncycastle.tls.Certificate
-
public class Certificate extends java.lang.ObjectParsing and encoding of a Certificate struct from RFC 4346.opaque ASN.1Cert<2^24-1>; struct { ASN.1Cert certificate_list<0..2^24-1>; } Certificate;- See Also:
Certificate
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCertificate.ParseOptions
-
Field Summary
Fields Modifier and Type Field Description protected CertificateEntry[]certificateEntryListprotected byte[]certificateRequestContextstatic CertificateEMPTY_CHAINstatic CertificateEMPTY_CHAIN_TLS13
-
Constructor Summary
Constructors Constructor Description Certificate(byte[] certificateRequestContext, CertificateEntry[] certificateEntryList)Certificate(TlsCertificate[] certificateList)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected static voidcalculateEndPointHash(TlsContext context, TlsCertificate cert, byte[] encoding, java.io.OutputStream output)protected CertificateEntry[]cloneCertificateEntryList()protected TlsCertificate[]cloneCertificateList()voidencode(TlsContext context, java.io.OutputStream messageOutput, java.io.OutputStream endPointHashOutput)Encode thisCertificateto anOutputStream, and optionally calculate the "end point hash" (per RFC 5929's tls-server-end-point binding).TlsCertificategetCertificateAt(int index)CertificateEntrygetCertificateEntryAt(int index)CertificateEntry[]getCertificateEntryList()TlsCertificate[]getCertificateList()byte[]getCertificateRequestContext()shortgetCertificateType()intgetLength()booleanisEmpty()static Certificateparse(Certificate.ParseOptions options, TlsContext context, java.io.InputStream messageInput, java.io.OutputStream endPointHashOutput)Parse aCertificatefrom anInputStream.static Certificateparse(TlsContext context, java.io.InputStream messageInput, java.io.OutputStream endPointHashOutput)Deprecated.Use version taking aCertificate.ParseOptionsargument instead.
-
-
-
Field Detail
-
EMPTY_CHAIN
public static final Certificate EMPTY_CHAIN
-
EMPTY_CHAIN_TLS13
public static final Certificate EMPTY_CHAIN_TLS13
-
certificateRequestContext
protected final byte[] certificateRequestContext
-
certificateEntryList
protected final CertificateEntry[] certificateEntryList
-
-
Constructor Detail
-
Certificate
public Certificate(TlsCertificate[] certificateList)
-
Certificate
public Certificate(byte[] certificateRequestContext, CertificateEntry[] certificateEntryList)
-
-
Method Detail
-
getCertificateRequestContext
public byte[] getCertificateRequestContext()
-
getCertificateList
public TlsCertificate[] getCertificateList()
- Returns:
- an array of
Certificaterepresenting a certificate chain.
-
getCertificateAt
public TlsCertificate getCertificateAt(int index)
-
getCertificateEntryAt
public CertificateEntry getCertificateEntryAt(int index)
-
getCertificateEntryList
public CertificateEntry[] getCertificateEntryList()
-
getCertificateType
public short getCertificateType()
-
getLength
public int getLength()
-
isEmpty
public boolean isEmpty()
- Returns:
trueif this certificate chain contains no certificates, orfalseotherwise.
-
encode
public void encode(TlsContext context, java.io.OutputStream messageOutput, java.io.OutputStream endPointHashOutput) throws java.io.IOException
Encode thisCertificateto anOutputStream, and optionally calculate the "end point hash" (per RFC 5929's tls-server-end-point binding).- Parameters:
messageOutput- theOutputStreamto encode to.endPointHashOutput- theOutputStreamto write the "end point hash" (or null).- Throws:
java.io.IOException
-
parse
public static Certificate parse(TlsContext context, java.io.InputStream messageInput, java.io.OutputStream endPointHashOutput) throws java.io.IOException
Deprecated.Use version taking aCertificate.ParseOptionsargument instead.Parse aCertificatefrom anInputStream.- Parameters:
context- theTlsContextof the current connection.messageInput- theInputStreamto parse from.endPointHashOutput- theOutputStreamto write the "end point hash" (or null).- Returns:
- a
Certificateobject. - Throws:
java.io.IOException
-
parse
public static Certificate parse(Certificate.ParseOptions options, TlsContext context, java.io.InputStream messageInput, java.io.OutputStream endPointHashOutput) throws java.io.IOException
Parse aCertificatefrom anInputStream.- Parameters:
options- theCertificate.ParseOptionsto apply during parsing.context- theTlsContextof the current connection.messageInput- theInputStreamto parse from.endPointHashOutput- theOutputStreamto write the "end point hash" (or null).- Returns:
- a
Certificateobject. - Throws:
java.io.IOException
-
calculateEndPointHash
protected static void calculateEndPointHash(TlsContext context, TlsCertificate cert, byte[] encoding, java.io.OutputStream output) throws java.io.IOException
- Throws:
java.io.IOException
-
cloneCertificateList
protected TlsCertificate[] cloneCertificateList()
-
cloneCertificateEntryList
protected CertificateEntry[] cloneCertificateEntryList()
-
-