Package org.bouncycastle.tls
Class AbstractTlsClient
java.lang.Object
org.bouncycastle.tls.AbstractTlsPeer
org.bouncycastle.tls.AbstractTlsClient
- Direct Known Subclasses:
DefaultTlsClient
,PSKTlsClient
,SRPTlsClient
Base class for a TLS client.
-
Field Summary
Modifier and TypeFieldDescriptionprotected int[]
protected TlsClientContext
protected ProtocolVersion[]
protected Vector
protected Vector
protected Vector
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
allowUnexpectedServerExtension
(Integer extensionType, byte[] extensionData) protected void
checkForUnexpectedServerExtension
(Hashtable serverExtensions, Integer extensionType) protected short[]
protected short[]
protected Vector
protected CertificateStatusRequest
int[]
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.Return theexternal PSKs
to offer in the ClientHello.protected Vector
protected Vector
protected byte[]
RFC 9146 DTLS connection ID.protected Vector
Return the session this client wants to resume, if any.protected Vector
protected Vector
getSupportedGroups
(Vector namedGroupRoles) The defaultgetClientExtensions()
implementation calls this to determine which named groups to include in the supported_groups extension for the ClientHello.protected Vector
protected Vector
protected Vector
void
init
(TlsClientContext context) boolean
void
Notifies the peer that a new handshake is about to begin.void
notifyNewSessionTicket
(NewSessionTicket newSessionTicket) RFC 5077 3.3.void
notifySelectedCipherSuite
(int selectedCipherSuite) void
notifySelectedPSK
(TlsPSK selectedPSK) void
notifyServerVersion
(ProtocolVersion serverVersion) void
notifySessionID
(byte[] sessionID) Notifies the client of the session_id sent in the ServerHello.void
notifySessionToResume
(TlsSession session) Notifies the client of the session that will be offered in ClientHello for resumption, if any.void
processServerExtensions
(Hashtable serverExtensions) The TlsClientProtocol implementation validates that any server extensions received correspond to client extensions sent.void
processServerSupplementalData
(Vector serverSupplementalData) boolean
Methods inherited from class org.bouncycastle.tls.AbstractTlsPeer
allowLegacyResumption, cancel, getCrypto, getHandshakeResendTimeMillis, getHandshakeTimeoutMillis, getHeartbeat, getHeartbeatPolicy, getKeyExchangeFactory, getMaxCertificateChainLength, getMaxHandshakeMessageSize, getPskKeyExchangeModes, getRenegotiationPolicy, getSupportedCipherSuites, getSupportedVersions, notifyAlertRaised, notifyAlertReceived, notifyCloseHandle, notifyConnectionClosed, notifyHandshakeComplete, notifySecureRenegotiation, requiresCloseNotify, requiresExtendedMasterSecret, shouldCheckSigAlgOfPeerCerts, shouldUseExtendedMasterSecret, shouldUseExtendedPadding, shouldUseGMTUnixTime
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bouncycastle.tls.TlsClient
getAuthentication
Methods inherited from interface org.bouncycastle.tls.TlsPeer
allowLegacyResumption, cancel, getCrypto, getHandshakeResendTimeMillis, getHandshakeTimeoutMillis, getHeartbeat, getHeartbeatPolicy, getKeyExchangeFactory, getMaxCertificateChainLength, getMaxHandshakeMessageSize, getPskKeyExchangeModes, getRenegotiationPolicy, notifyAlertRaised, notifyAlertReceived, notifyCloseHandle, notifyConnectionClosed, notifyHandshakeComplete, notifySecureRenegotiation, requiresCloseNotify, requiresExtendedMasterSecret, shouldCheckSigAlgOfPeerCerts, shouldUseExtendedMasterSecret, shouldUseExtendedPadding, shouldUseGMTUnixTime
-
Field Details
-
context
-
protocolVersions
-
cipherSuites
protected int[] cipherSuites -
supportedGroups
-
supportedSignatureAlgorithms
-
supportedSignatureAlgorithmsCert
-
-
Constructor Details
-
AbstractTlsClient
-
-
Method Details
-
allowUnexpectedServerExtension
protected boolean allowUnexpectedServerExtension(Integer extensionType, byte[] extensionData) throws IOException - Throws:
IOException
-
getNamedGroupRoles
-
checkForUnexpectedServerExtension
protected void checkForUnexpectedServerExtension(Hashtable serverExtensions, Integer extensionType) throws IOException - Throws:
IOException
-
getNewConnectionID
protected byte[] getNewConnectionID()RFC 9146 DTLS connection ID. The defaultgetClientExtensions()
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:")- Returns:
- The connection ID to use.
-
getPSKIdentity
- Specified by:
getPSKIdentity
in interfaceTlsClient
- Throws:
IOException
-
getSRPIdentity
- Specified by:
getSRPIdentity
in interfaceTlsClient
- Throws:
IOException
-
getDHGroupVerifier
- Specified by:
getDHGroupVerifier
in interfaceTlsClient
-
getSRPConfigVerifier
- Specified by:
getSRPConfigVerifier
in interfaceTlsClient
-
getCertificateAuthorities
-
getProtocolNames
-
getCertificateStatusRequest
-
getMultiCertStatusRequest
- Returns:
- a
Vector
ofCertificateStatusRequestItemV2
(or null).
-
getSNIServerNames
-
getSupportedGroups
The defaultgetClientExtensions()
implementation calls this to determine which named groups to include in the supported_groups extension for the ClientHello.- Parameters:
namedGroupRoles
- Thenamed 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:
- a
Vector
ofInteger
. SeeNamedGroup
for group constants.
-
getSupportedSignatureAlgorithms
-
getSupportedSignatureAlgorithmsCert
-
getTrustedCAIndication
-
getAllowedClientCertificateTypes
protected short[] getAllowedClientCertificateTypes() -
getAllowedServerCertificateTypes
protected short[] getAllowedServerCertificateTypes() -
init
-
getProtocolVersions
- Specified by:
getProtocolVersions
in interfaceTlsPeer
-
getCipherSuites
public int[] getCipherSuites()- Specified by:
getCipherSuites
in interfaceTlsPeer
-
notifyHandshakeBeginning
Description copied from interface:TlsPeer
Notifies the peer that a new handshake is about to begin.- Specified by:
notifyHandshakeBeginning
in interfaceTlsPeer
- Overrides:
notifyHandshakeBeginning
in classAbstractTlsPeer
- Throws:
IOException
-
getSessionToResume
Description copied from interface:TlsClient
Return the session this client wants to resume, if any. Note that the peer's certificate chain for the session (if any) may need to be periodically revalidated.- Specified by:
getSessionToResume
in interfaceTlsClient
- Returns:
- A
TlsSession
representing the resumable session to be used for this connection, or null to use a new session. - See Also:
-
getExternalPSKs
Description copied from interface:TlsClient
Return theexternal PSKs
to offer in the ClientHello. Note that this will only be called when TLS 1.3 or higher is amongst the offered protocol versions.- Specified by:
getExternalPSKs
in interfaceTlsClient
- Returns:
- a
Vector
ofTlsPSKExternal
instances, or null if none should be offered.
-
isFallback
public boolean isFallback()- Specified by:
isFallback
in interfaceTlsClient
-
getClientExtensions
- Specified by:
getClientExtensions
in interfaceTlsClient
- Throws:
IOException
-
shouldUseCompatibilityMode
public boolean shouldUseCompatibilityMode()- Specified by:
shouldUseCompatibilityMode
in interfaceTlsClient
-
notifyServerVersion
- Specified by:
notifyServerVersion
in interfaceTlsClient
- Throws:
IOException
-
notifySessionToResume
Description copied from interface:TlsClient
Notifies the client of the session that will be offered in ClientHello for resumption, if any. This will be either the session returned fromTlsClient.getSessionToResume()
or null if that session was unusable. NOTE: the actual negotiated session_id is notified byTlsClient.notifySessionID(byte[])
.- Specified by:
notifySessionToResume
in interfaceTlsClient
- Parameters:
session
- TheTlsSession
representing the resumable session to be offered for this connection, or null if there is none.- See Also:
-
notifySessionID
public void notifySessionID(byte[] sessionID) Description copied from interface:TlsClient
Notifies the client of the session_id sent in the ServerHello.- Specified by:
notifySessionID
in interfaceTlsClient
- Parameters:
sessionID
-- See Also:
-
notifySelectedCipherSuite
public void notifySelectedCipherSuite(int selectedCipherSuite) - Specified by:
notifySelectedCipherSuite
in interfaceTlsClient
-
notifySelectedPSK
- Specified by:
notifySelectedPSK
in interfaceTlsClient
- Throws:
IOException
-
processServerExtensions
Description copied from interface:TlsClient
The TlsClientProtocol implementation validates that any server extensions received correspond to client extensions sent. If further processing of the server extensions is needed, it can be done in this callback. NOTE: This is not called for session resumption handshakes.- Specified by:
processServerExtensions
in interfaceTlsClient
- Parameters:
serverExtensions
- (Integer -> byte[])- Throws:
IOException
-
processServerSupplementalData
- Specified by:
processServerSupplementalData
in interfaceTlsClient
- Throws:
IOException
-
getClientSupplementalData
- Specified by:
getClientSupplementalData
in interfaceTlsClient
- Throws:
IOException
-
notifyNewSessionTicket
Description copied from interface:TlsClient
RFC 5077 3.3. NewSessionTicket Handshake MessageThis method will be called (only) when a NewSessionTicket handshake message is received. The ticket is opaque to the client and clients MUST NOT examine the ticket under the assumption that it complies with e.g. RFC 5077 4. Recommended Ticket Construction.
- Specified by:
notifyNewSessionTicket
in interfaceTlsClient
- Parameters:
newSessionTicket
- The ticket.- Throws:
IOException
-