Package org.bouncycastle.tls
Class Certificate
- java.lang.Object
-
- org.bouncycastle.tls.Certificate
-
public class Certificate extends java.lang.Object
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
-
-
Field Summary
Fields Modifier and Type Field Description protected TlsCertificate[]
certificateList
protected byte[]
certificateRequestContext
static Certificate
EMPTY_CHAIN
-
Constructor Summary
Constructors Constructor Description Certificate(TlsCertificate[] certificateList)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static void
calculateEndPointHash(TlsContext context, TlsCertificate cert, byte[] encoding, java.io.OutputStream output)
protected TlsCertificate[]
cloneCertificateList()
void
encode(TlsContext context, java.io.OutputStream messageOutput, java.io.OutputStream endPointHashOutput)
Encode thisCertificate
to anOutputStream
, and optionally calculate the "end point hash" (per RFC 5929's tls-server-end-point binding).TlsCertificate
getCertificateAt(int index)
TlsCertificate[]
getCertificateList()
byte[]
getCertificateRequestContext()
int
getLength()
boolean
isEmpty()
static Certificate
parse(TlsContext context, java.io.InputStream messageInput, java.io.OutputStream endPointHashOutput)
Parse aCertificate
from anInputStream
.
-
-
-
Field Detail
-
EMPTY_CHAIN
public static final Certificate EMPTY_CHAIN
-
certificateRequestContext
protected final byte[] certificateRequestContext
-
certificateList
protected final TlsCertificate[] certificateList
-
-
Constructor Detail
-
Certificate
public Certificate(TlsCertificate[] certificateList)
-
-
Method Detail
-
getCertificateRequestContext
public byte[] getCertificateRequestContext()
-
getCertificateList
public TlsCertificate[] getCertificateList()
- Returns:
- an array of
Certificate
representing a certificate chain.
-
getCertificateAt
public TlsCertificate getCertificateAt(int index)
-
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, java.io.OutputStream messageOutput, java.io.OutputStream endPointHashOutput) throws java.io.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:
java.io.IOException
-
parse
public static Certificate parse(TlsContext context, java.io.InputStream messageInput, java.io.OutputStream endPointHashOutput) throws java.io.IOException
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:
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()
-
-