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:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected final CertificateEntry[]
protected final byte[]
protected final short
static final Certificate
static final Certificate
-
Constructor Summary
ConstructorDescriptionCertificate
(byte[] certificateRequestContext, CertificateEntry[] certificateEntryList) Certificate
(short certificateType, byte[] certificateRequestContext, CertificateEntry[] certificateEntryList) Certificate
(TlsCertificate[] certificateList) -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
calculateEndPointHash
(TlsContext context, TlsCertificate cert, byte[] encoding, OutputStream output) protected CertificateEntry[]
protected TlsCertificate[]
void
encode
(TlsContext context, OutputStream messageOutput, OutputStream endPointHashOutput) Encode thisCertificate
to anOutputStream
, and optionally calculate the "end point hash" (per RFC 5929's tls-server-end-point binding).getCertificateAt
(int index) getCertificateEntryAt
(int index) byte[]
short
int
boolean
isEmpty()
static Certificate
parse
(Certificate.ParseOptions options, TlsContext context, InputStream messageInput, OutputStream endPointHashOutput) Parse aCertificate
from anInputStream
.static Certificate
parse
(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
Certificate
representing a certificate chain.
-
getCertificateAt
-
getCertificateEntryAt
-
getCertificateEntryList
-
getCertificateType
public short getCertificateType() -
getLength
public int getLength() -
isEmpty
public boolean isEmpty()- Returns:
true
if this certificate chain contains no certificates, orfalse
otherwise.
-
encode
public void encode(TlsContext context, OutputStream messageOutput, OutputStream endPointHashOutput) throws IOException Encode thisCertificate
to anOutputStream
, and optionally calculate the "end point hash" (per RFC 5929's tls-server-end-point binding).- Parameters:
messageOutput
- theOutputStream
to encode to.endPointHashOutput
- theOutputStream
to 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.ParseOptions
argument instead.Parse aCertificate
from anInputStream
.- Parameters:
context
- theTlsContext
of the current connection.messageInput
- theInputStream
to parse from.endPointHashOutput
- theOutputStream
to write the "end point hash" (or null).- Returns:
- a
Certificate
object. - Throws:
IOException
-
parse
public static Certificate parse(Certificate.ParseOptions options, TlsContext context, InputStream messageInput, OutputStream endPointHashOutput) throws IOException Parse aCertificate
from anInputStream
.- Parameters:
options
- theCertificate.ParseOptions
to apply during parsing.context
- theTlsContext
of the current connection.messageInput
- theInputStream
to parse from.endPointHashOutput
- theOutputStream
to write the "end point hash" (or null).- Returns:
- a
Certificate
object. - Throws:
IOException
-
calculateEndPointHash
protected static void calculateEndPointHash(TlsContext context, TlsCertificate cert, byte[] encoding, OutputStream output) throws IOException - Throws:
IOException
-
cloneCertificateList
-
cloneCertificateEntryList
-
Certificate.ParseOptions
argument instead.