Table of Contents

Class AbstractTlsClient

Namespace
Org.BouncyCastle.Tls
Assembly
BouncyCastle.Cryptography.dll

Base class for a TLS client.

public abstract class AbstractTlsClient : AbstractTlsPeer, TlsClient, TlsPeer
Inheritance
AbstractTlsClient
Implements
Derived
Inherited Members

Constructors

AbstractTlsClient(TlsCrypto)

protected AbstractTlsClient(TlsCrypto crypto)

Parameters

crypto TlsCrypto

Fields

m_cipherSuites

protected int[] m_cipherSuites

Field Value

int[]

m_context

protected TlsClientContext m_context

Field Value

TlsClientContext

m_protocolVersions

protected ProtocolVersion[] m_protocolVersions

Field Value

ProtocolVersion[]

m_supportedGroups

protected IList<int> m_supportedGroups

Field Value

IList<int>

m_supportedSignatureAlgorithms

protected IList<SignatureAndHashAlgorithm> m_supportedSignatureAlgorithms

Field Value

IList<SignatureAndHashAlgorithm>

m_supportedSignatureAlgorithmsCert

protected IList<SignatureAndHashAlgorithm> m_supportedSignatureAlgorithmsCert

Field Value

IList<SignatureAndHashAlgorithm>

Methods

AllowUnexpectedServerExtension(int, byte[])

protected virtual bool AllowUnexpectedServerExtension(int extensionType, byte[] extensionData)

Parameters

extensionType int
extensionData byte[]

Returns

bool

Exceptions

IOException

CheckForUnexpectedServerExtension(IDictionary<int, byte[]>, int)

protected virtual void CheckForUnexpectedServerExtension(IDictionary<int, byte[]> serverExtensions, int extensionType)

Parameters

serverExtensions IDictionary<int, byte[]>
extensionType int

Exceptions

IOException

GetAllowedClientCertificateTypes()

protected virtual short[] GetAllowedClientCertificateTypes()

Returns

short[]

GetAllowedServerCertificateTypes()

protected virtual short[] GetAllowedServerCertificateTypes()

Returns

short[]

GetAuthentication()

public abstract TlsAuthentication GetAuthentication()

Returns

TlsAuthentication

Exceptions

IOException

GetCertificateAuthorities()

protected virtual IList<X509Name> GetCertificateAuthorities()

Returns

IList<X509Name>

GetCertificateStatusRequest()

protected virtual CertificateStatusRequest GetCertificateStatusRequest()

Returns

CertificateStatusRequest

GetCipherSuites()

public override int[] GetCipherSuites()

Returns

int[]

GetClientExtensions()

public virtual IDictionary<int, byte[]> GetClientExtensions()

Returns

IDictionary<int, byte[]>

Exceptions

IOException

GetClientSupplementalData()

public virtual IList<SupplementalDataEntry> GetClientSupplementalData()

Returns

IList<SupplementalDataEntry>

Exceptions

IOException

GetDHGroupVerifier()

public virtual TlsDHGroupVerifier GetDHGroupVerifier()

Returns

TlsDHGroupVerifier

Exceptions

IOException

GetEarlyKeyShareGroups()

If this client is offering TLS 1.3 or higher, this method may be called to determine for which groups a key share should be included in the initial ClientHello.

public virtual IList<int> GetEarlyKeyShareGroups()

Returns

IList<int>

an IList<T> of named group values, possibly empty or null.

Remarks

Groups that were not included in the supported_groups extension (by GetClientExtensions() will be ignored. The protocol will then add a suitable key_share extension to the ClientHello extensions.

GetExternalPsks()

Return the external PSKs to offer in the ClientHello.

public virtual IList<TlsPskExternal> GetExternalPsks()

Returns

IList<TlsPskExternal>

an IList<T> of TlsPskExternal instances, or null if none should be offered.

Remarks

This will only be called when TLS 1.3 or higher is amongst the offered protocol versions.

GetMultiCertStatusRequest()

protected virtual IList<CertificateStatusRequestItemV2> GetMultiCertStatusRequest()

Returns

IList<CertificateStatusRequestItemV2>

an IList<T> of CertificateStatusRequestItemV2 (or null).

GetNamedGroupRoles()

protected virtual IList<int> GetNamedGroupRoles()

Returns

IList<int>

GetNewConnectionID()

RFC 9146 DTLS connection ID.

protected virtual byte[] GetNewConnectionID()

Returns

byte[]

The connection ID to use.

Remarks

The default GetClientExtensions() implementation calls this to get the connection_id extension the client will send. As future communication doesn't include the connection IDs length, this should either be fixed-length or include the connection ID's length. (see explanation in RFC 9146 4. "cid:")

GetProtocolNames()

protected virtual IList<ProtocolName> GetProtocolNames()

Returns

IList<ProtocolName>

GetProtocolVersions()

public override ProtocolVersion[] GetProtocolVersions()

Returns

ProtocolVersion[]

GetPskIdentity()

public virtual TlsPskIdentity GetPskIdentity()

Returns

TlsPskIdentity

Exceptions

IOException

GetSessionToResume()

Return the session this client wants to resume, if any.

public virtual TlsSession GetSessionToResume()

Returns

TlsSession

A TlsSession representing the resumable session to be used for this connection, or null to use a new session.

Remarks

Note that the peer's certificate chain for the session (if any) may need to be periodically revalidated.

See Also

GetSniServerNames()

protected virtual IList<ServerName> GetSniServerNames()

Returns

IList<ServerName>

GetSrpConfigVerifier()

public virtual TlsSrpConfigVerifier GetSrpConfigVerifier()

Returns

TlsSrpConfigVerifier

Exceptions

IOException

GetSrpIdentity()

public virtual TlsSrpIdentity GetSrpIdentity()

Returns

TlsSrpIdentity

Exceptions

IOException

GetSupportedGroups(IList<int>)

The default GetClientExtensions() implementation calls this to determine which named groups to include in the supported_groups extension for the ClientHello.

protected virtual IList<int> GetSupportedGroups(IList<int> namedGroupRoles)

Parameters

namedGroupRoles IList<int>

The named group roles for which there should be at least one supported group. By default this is inferred from the offered cipher suites and signature algorithms.

Returns

IList<int>

an IList<T> of int. See NamedGroup for group constants.

GetSupportedSignatureAlgorithms()

protected virtual IList<SignatureAndHashAlgorithm> GetSupportedSignatureAlgorithms()

Returns

IList<SignatureAndHashAlgorithm>

GetSupportedSignatureAlgorithmsCert()

protected virtual IList<SignatureAndHashAlgorithm> GetSupportedSignatureAlgorithmsCert()

Returns

IList<SignatureAndHashAlgorithm>

GetTrustedCAIndication()

protected virtual IList<TrustedAuthority> GetTrustedCAIndication()

Returns

IList<TrustedAuthority>

Init(TlsClientContext)

public virtual void Init(TlsClientContext context)

Parameters

context TlsClientContext

IsFallback()

public virtual bool IsFallback()

Returns

bool

NotifyHandshakeBeginning()

public override void NotifyHandshakeBeginning()

Exceptions

IOException

NotifyNewSessionTicket(NewSessionTicket)

public virtual void NotifyNewSessionTicket(NewSessionTicket newSessionTicket)

Parameters

newSessionTicket NewSessionTicket

Exceptions

IOException

NotifySelectedCipherSuite(int)

public virtual void NotifySelectedCipherSuite(int selectedCipherSuite)

Parameters

selectedCipherSuite int

NotifySelectedPsk(TlsPsk)

public virtual void NotifySelectedPsk(TlsPsk selectedPsk)

Parameters

selectedPsk TlsPsk

Exceptions

IOException

NotifyServerVersion(ProtocolVersion)

public virtual void NotifyServerVersion(ProtocolVersion serverVersion)

Parameters

serverVersion ProtocolVersion

Exceptions

IOException

NotifySessionID(byte[])

Notifies the client of the session_id sent in the ServerHello.

public virtual void NotifySessionID(byte[] sessionID)

Parameters

sessionID byte[]
See Also

NotifySessionToResume(TlsSession)

Notifies the client of the session that will be offered in ClientHello for resumption, if any.

public virtual void NotifySessionToResume(TlsSession session)

Parameters

session TlsSession

The TlsSession representing the resumable session to be offered for this connection, or null if there is none.

Remarks

This will be either the session returned from {@link #getSessionToResume()} or null if that session was unusable. NOTE: the actual negotiated session_id is notified by NotifySessionID(byte[]).

See Also

ProcessServerExtensions(IDictionary<int, byte[]>)

public virtual void ProcessServerExtensions(IDictionary<int, byte[]> serverExtensions)

Parameters

serverExtensions IDictionary<int, byte[]>

Exceptions

IOException

ProcessServerSupplementalData(IList<SupplementalDataEntry>)

public virtual void ProcessServerSupplementalData(IList<SupplementalDataEntry> serverSupplementalData)

Parameters

serverSupplementalData IList<SupplementalDataEntry>

Exceptions

IOException

ShouldUseCompatibilityMode()

public virtual bool ShouldUseCompatibilityMode()

Returns

bool