Top Description Inners Fields Constructors Methods
org.bouncycastle.tls

public Class Certificate

extends Object
Class Inheritance
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream, .OutputStream, java.util.Hashtable, .Vector, org.bouncycastle.tls.crypto.TlsCertificate, .TlsCrypto

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
org.bouncycastle.asn1.x509.Certificate

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
protected final CertificateEntry[]
protected final byte[]
protected final short
private static final CertificateEntry[]
private static final TlsCertificate[]
public static final Certificate
public static final Certificate

Constructor Summary

AccessConstructor and Description
public
Certificate(TlsCertificate[] certificateList)

public
Certificate(byte[] certificateRequestContext, CertificateEntry[] certificateEntryList)

public
Certificate(short certificateType, byte[] certificateRequestContext, CertificateEntry[] certificateEntryList)

Method Summary

Modifier and TypeMethod and Description
protected static void
calculateEndPointHash(TlsContext context, TlsCertificate cert, byte[] encoding, OutputStream output)

protected CertificateEntry[]
protected TlsCertificate[]
private static CertificateEntry[]
convert(TlsCertificate[] certificateList)

public void
encode(TlsContext context, OutputStream
the OutputStream to encode to.
messageOutput
,
OutputStream
the OutputStream to write the "end point hash" (or null).
endPointHashOutput
)

Encode this Certificate to an OutputStream, and optionally calculate the "end point hash" (per RFC 5929's tls-server-end-point binding).

public TlsCertificate
getCertificateAt(int index)

public CertificateEntry
public CertificateEntry[]
public TlsCertificate[]

Returns:

an array of org.bouncycastle.asn1.x509.Certificate representing a certificate chain.
getCertificateList
()

public byte[]
public short
public int
public boolean

Returns:

true if this certificate chain contains no certificates, or false otherwise.
isEmpty
()

public static Certificate

Returns:

a Certificate object.
parse
(TlsContext
the TlsContext of the current connection.
context
,
InputStream
the InputStream to parse from.
messageInput
,
OutputStream
the OutputStream to write the "end point hash" (or null).
endPointHashOutput
)

Deprecated Use version taking a ParseOptions argument instead.
Parse a Certificate from an InputStream.
public static Certificate

Returns:

a Certificate object.
parse
(Certificate.ParseOptions
the ParseOptions to apply during parsing.
options
,
TlsContext
the TlsContext of the current connection.
context
,
InputStream
the InputStream to parse from.
messageInput
,
OutputStream
the OutputStream to write the "end point hash" (or null).
endPointHashOutput
)

Parse a Certificate from an InputStream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

certificateEntryListback to summary
protected final CertificateEntry[] certificateEntryList
certificateRequestContextback to summary
protected final byte[] certificateRequestContext
certificateTypeback to summary
protected final short certificateType
EMPTY_CERT_ENTRIESback to summary
private static final CertificateEntry[] EMPTY_CERT_ENTRIES
EMPTY_CERTSback to summary
private static final TlsCertificate[] EMPTY_CERTS
EMPTY_CHAINback to summary
public static final Certificate EMPTY_CHAIN
EMPTY_CHAIN_TLS13back to summary
public static final Certificate EMPTY_CHAIN_TLS13

Constructor Detail

Certificateback to summary
public Certificate(TlsCertificate[] certificateList)
Certificateback to summary
public Certificate(byte[] certificateRequestContext, CertificateEntry[] certificateEntryList)
Certificateback to summary
public Certificate(short certificateType, byte[] certificateRequestContext, CertificateEntry[] certificateEntryList)

Method Detail

calculateEndPointHashback to summary
protected static void calculateEndPointHash(TlsContext context, TlsCertificate cert, byte[] encoding, OutputStream output) throws IOException
cloneCertificateEntryListback to summary
protected CertificateEntry[] cloneCertificateEntryList()
cloneCertificateListback to summary
protected TlsCertificate[] cloneCertificateList()
convertback to summary
private static CertificateEntry[] convert(TlsCertificate[] certificateList)
encodeback to summary
public void encode(TlsContext context, OutputStream messageOutput, OutputStream endPointHashOutput) throws IOException

Encode this Certificate to an OutputStream, and optionally calculate the "end point hash" (per RFC 5929's tls-server-end-point binding).

Parameters
messageOutput:OutputStream

the OutputStream to encode to.

endPointHashOutput:OutputStream

the OutputStream to write the "end point hash" (or null).

getCertificateAtback to summary
public TlsCertificate getCertificateAt(int index)
getCertificateEntryAtback to summary
public CertificateEntry getCertificateEntryAt(int index)
getCertificateEntryListback to summary
public CertificateEntry[] getCertificateEntryList()
getCertificateListback to summary
public TlsCertificate[] getCertificateList()
Returns:TlsCertificate[]

an array of org.bouncycastle.asn1.x509.Certificate representing a certificate chain.

getCertificateRequestContextback to summary
public byte[] getCertificateRequestContext()
getCertificateTypeback to summary
public short getCertificateType()
getLengthback to summary
public int getLength()
isEmptyback to summary
public boolean isEmpty()
Returns:boolean

true if this certificate chain contains no certificates, or false otherwise.

parseback to summary
public static Certificate parse(TlsContext context, InputStream messageInput, OutputStream endPointHashOutput) throws IOException

Deprecated

Use version taking a ParseOptions argument instead.

Parse a Certificate from an InputStream.

Parameters
context:TlsContext

the TlsContext of the current connection.

messageInput:InputStream

the InputStream to parse from.

endPointHashOutput:OutputStream

the OutputStream to write the "end point hash" (or null).

Returns:Certificate

a Certificate object.

parseback to summary
public static Certificate parse(Certificate.ParseOptions options, TlsContext context, InputStream messageInput, OutputStream endPointHashOutput) throws IOException

Parse a Certificate from an InputStream.

Parameters
options:Certificate.ParseOptions

the ParseOptions to apply during parsing.

context:TlsContext

the TlsContext of the current connection.

messageInput:InputStream

the InputStream to parse from.

endPointHashOutput:OutputStream

the OutputStream to write the "end point hash" (or null).

Returns:Certificate

a Certificate object.

org.bouncycastle.tls back to summary

public Class Certificate.ParseOptions

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private short
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public short
public int
public Certificate.ParseOptions
setCertificateType(short certificateType)

Set the CertificateType according to the IANA TLS Certificate Types registry

public Certificate.ParseOptions
setMaxChainLength(int maxChainLength)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

certificateTypeback to summary
private short certificateType
maxChainLengthback to summary
private int maxChainLength

Constructor Detail

ParseOptionsback to summary
public ParseOptions()

Method Detail

getCertificateTypeback to summary
public short getCertificateType()
getMaxChainLengthback to summary
public int getMaxChainLength()
setCertificateTypeback to summary
public Certificate.ParseOptions setCertificateType(short certificateType)

Set the CertificateType according to the IANA TLS Certificate Types registry

setMaxChainLengthback to summary
public Certificate.ParseOptions setMaxChainLength(int maxChainLength)