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
FieldsModifier and TypeFieldDescriptionprotected int[]protected TlsClientContextprotected ProtocolVersion[]protected Vectorprotected Vectorprotected Vector -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanallowUnexpectedServerExtension(Integer extensionType, byte[] extensionData) protected voidcheckForUnexpectedServerExtension(Hashtable serverExtensions, Integer extensionType) protected short[]protected short[]protected Vectorprotected CertificateStatusRequestint[]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 PSKsto offer in the ClientHello.protected Vectorprotected Vectorprotected byte[]RFC 9146 DTLS connection ID.protected VectorReturn the session this client wants to resume, if any.protected Vectorprotected VectorgetSupportedGroups(Vector namedGroupRoles) The defaultgetClientExtensions()implementation calls this to determine which named groups to include in the supported_groups extension for the ClientHello.protected Vectorprotected Vectorprotected Vectorvoidinit(TlsClientContext context) booleanvoidNotifies the peer that a new handshake is about to begin.voidnotifyNewSessionTicket(NewSessionTicket newSessionTicket) RFC 5077 3.3.voidnotifySelectedCipherSuite(int selectedCipherSuite) voidnotifySelectedPSK(TlsPSK selectedPSK) voidnotifyServerVersion(ProtocolVersion serverVersion) voidnotifySessionID(byte[] sessionID) Notifies the client of the session_id sent in the ServerHello.voidnotifySessionToResume(TlsSession session) Notifies the client of the session that will be offered in ClientHello for resumption, if any.voidprocessServerExtensions(Hashtable serverExtensions) The TlsClientProtocol implementation validates that any server extensions received correspond to client extensions sent.voidprocessServerSupplementalData(Vector serverSupplementalData) booleanMethods 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, shouldUseGMTUnixTimeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bouncycastle.tls.TlsClient
getAuthenticationMethods 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:
getPSKIdentityin interfaceTlsClient- Throws:
IOException
-
getSRPIdentity
- Specified by:
getSRPIdentityin interfaceTlsClient- Throws:
IOException
-
getDHGroupVerifier
- Specified by:
getDHGroupVerifierin interfaceTlsClient
-
getSRPConfigVerifier
- Specified by:
getSRPConfigVerifierin interfaceTlsClient
-
getCertificateAuthorities
-
getProtocolNames
-
getCertificateStatusRequest
-
getMultiCertStatusRequest
- Returns:
- a
VectorofCertificateStatusRequestItemV2(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 rolesfor which there should be at least one supported group. By default this is inferred from the offered cipher suites and signature algorithms.- Returns:
- a
VectorofInteger. SeeNamedGroupfor group constants.
-
getSupportedSignatureAlgorithms
-
getSupportedSignatureAlgorithmsCert
-
getTrustedCAIndication
-
getAllowedClientCertificateTypes
protected short[] getAllowedClientCertificateTypes() -
getAllowedServerCertificateTypes
protected short[] getAllowedServerCertificateTypes() -
init
-
getProtocolVersions
- Specified by:
getProtocolVersionsin interfaceTlsPeer
-
getCipherSuites
public int[] getCipherSuites()- Specified by:
getCipherSuitesin interfaceTlsPeer
-
notifyHandshakeBeginning
Description copied from interface:TlsPeerNotifies the peer that a new handshake is about to begin.- Specified by:
notifyHandshakeBeginningin interfaceTlsPeer- Overrides:
notifyHandshakeBeginningin classAbstractTlsPeer- Throws:
IOException
-
getSessionToResume
Description copied from interface:TlsClientReturn 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:
getSessionToResumein interfaceTlsClient- Returns:
- A
TlsSessionrepresenting the resumable session to be used for this connection, or null to use a new session. - See Also:
-
getExternalPSKs
Description copied from interface:TlsClientReturn theexternal PSKsto 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:
getExternalPSKsin interfaceTlsClient- Returns:
- a
VectorofTlsPSKExternalinstances, or null if none should be offered.
-
isFallback
public boolean isFallback()- Specified by:
isFallbackin interfaceTlsClient
-
getClientExtensions
- Specified by:
getClientExtensionsin interfaceTlsClient- Throws:
IOException
-
shouldUseCompatibilityMode
public boolean shouldUseCompatibilityMode()- Specified by:
shouldUseCompatibilityModein interfaceTlsClient
-
notifyServerVersion
- Specified by:
notifyServerVersionin interfaceTlsClient- Throws:
IOException
-
notifySessionToResume
Description copied from interface:TlsClientNotifies 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:
notifySessionToResumein interfaceTlsClient- Parameters:
session- TheTlsSessionrepresenting 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:TlsClientNotifies the client of the session_id sent in the ServerHello.- Specified by:
notifySessionIDin interfaceTlsClient- See Also:
-
notifySelectedCipherSuite
public void notifySelectedCipherSuite(int selectedCipherSuite) - Specified by:
notifySelectedCipherSuitein interfaceTlsClient
-
notifySelectedPSK
- Specified by:
notifySelectedPSKin interfaceTlsClient- Throws:
IOException
-
processServerExtensions
Description copied from interface:TlsClientThe 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:
processServerExtensionsin interfaceTlsClient- Parameters:
serverExtensions- (Integer -> byte[])- Throws:
IOException
-
processServerSupplementalData
- Specified by:
processServerSupplementalDatain interfaceTlsClient- Throws:
IOException
-
getClientSupplementalData
- Specified by:
getClientSupplementalDatain interfaceTlsClient- Throws:
IOException
-
notifyNewSessionTicket
Description copied from interface:TlsClientRFC 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:
notifyNewSessionTicketin interfaceTlsClient- Parameters:
newSessionTicket- The ticket.- Throws:
IOException
-