Package org.bouncycastle.tls
Class Certificate
java.lang.Object
org.bouncycastle.tls.Certificate
Parsing 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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CertificateEntry[]protected final byte[]protected final shortstatic final Certificatestatic final Certificate -
Constructor Summary
ConstructorsConstructorDescriptionCertificate(byte[] certificateRequestContext, CertificateEntry[] certificateEntryList) Certificate(short certificateType, byte[] certificateRequestContext, CertificateEntry[] certificateEntryList) Certificate(TlsCertificate[] certificateList) -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidcalculateEndPointHash(TlsContext context, TlsCertificate cert, byte[] encoding, OutputStream output) protected CertificateEntry[]protected TlsCertificate[]voidencode(TlsContext context, OutputStream messageOutput, OutputStream endPointHashOutput) Encode thisCertificateto anOutputStream, and optionally calculate the "end point hash" (per RFC 5929's tls-server-end-point binding).getCertificateAt(int index) getCertificateEntryAt(int index) byte[]shortintbooleanisEmpty()static Certificateparse(Certificate.ParseOptions options, TlsContext context, InputStream messageInput, OutputStream endPointHashOutput) Parse aCertificatefrom anInputStream.static Certificateparse(TlsContext context, InputStream messageInput, OutputStream endPointHashOutput) Deprecated.
-
Field Details
-
EMPTY_CHAIN
-
EMPTY_CHAIN_TLS13
-
certificateRequestContext
protected final byte[] certificateRequestContext -
certificateEntryList
-
certificateType
protected final short certificateType
-
-
Constructor Details
-
Certificate
-
Certificate
-
Certificate
public Certificate(short certificateType, byte[] certificateRequestContext, CertificateEntry[] certificateEntryList)
-
-
Method Details
-
getCertificateRequestContext
public byte[] getCertificateRequestContext() -
getCertificateList
- Returns:
- an array of
Certificaterepresenting a certificate chain.
-
getCertificateAt
-
getCertificateEntryAt
-
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, OutputStream messageOutput, OutputStream endPointHashOutput) throws 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:
IOException
-
parse
public static Certificate parse(TlsContext context, InputStream messageInput, OutputStream endPointHashOutput) throws 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:
IOException
-
parse
public static Certificate parse(Certificate.ParseOptions options, TlsContext context, InputStream messageInput, OutputStream endPointHashOutput) throws 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:
IOException
-
calculateEndPointHash
protected static void calculateEndPointHash(TlsContext context, TlsCertificate cert, byte[] encoding, OutputStream output) throws IOException - Throws:
IOException
-
cloneCertificateList
-
cloneCertificateEntryList
-
Certificate.ParseOptionsargument instead.