-
- All Superinterfaces:
MessageProcessor,TlsEngine,TrafficSecrets
- All Known Implementing Classes:
TlsClientEngineImpl
public interface TlsClientEngine extends TlsEngine
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidadd(Extension extension)Adds an extension to the list of extensions to be included in the ClientHello message.voidaddExtensions(java.util.List<Extension> extensions)Adds extensions to the list of extensions to be included in the ClientHello message.voidaddSupportedCiphers(java.util.List<TlsConstants.CipherSuite> supportedCiphers)Adds ciphers to the list of the symmetric cipher options supported by the client (specifically the record protection algorithm (including secret key length) and a hash to be used with HKDF), in descending order of client preference.java.util.List<NewSessionTicket>getNewSessionTickets()Returns tickets provided by the current connection.TlsConstants.CipherSuitegetSelectedCipher()Returns the selected (negotiated) cipher suite.java.util.List<java.security.cert.X509Certificate>getServerCertificateChain()Returns the server certificate chain.booleanhandshakeFinished()Returns whether the handshake has (successfully) finished.voidreceived(CertificateMessage certificateMessage, ProtectionKeysType protectedBy)voidreceived(CertificateRequestMessage certificateRequestMessage, ProtectionKeysType protectedBy)voidreceived(CertificateVerifyMessage certificateVerifyMessage, ProtectionKeysType protectedBy)voidreceived(EncryptedExtensions encryptedExtensions, ProtectionKeysType protectedBy)voidreceived(FinishedMessage finishedMessage, ProtectionKeysType protectedBy)voidreceived(NewSessionTicketMessage nst, ProtectionKeysType protectedBy)voidreceived(ServerHello serverHello, ProtectionKeysType protectedBy)voidsetClientCertificateCallback(java.util.function.Function<java.util.List<javax.security.auth.x500.X500Principal>,CertificateWithPrivateKey> callback)Set the callback to be used for selecting the client certificate (for client authentication).voidsetCompatibilityMode(boolean compatibilityMode)Sets the compatibility mode, see https://davidwong.fr/tls13/#appendix-D.4 Only for use in a TLS 1.3 context.voidsetHostnameVerifier(HostnameVerifier hostnameVerifier)Sets the hostname verifier to use for verifying the server name against the server certificate.voidsetNewSessionTicket(NewSessionTicket newSessionTicket)Add ticket to use for a new session.voidsetServerName(java.lang.String serverName)Set the name of the server that is connected; will be used in the SNI extension.voidsetTrustManager(javax.net.ssl.X509TrustManager customTrustManager)Sets the trust manager to use for verifying the server certificate.voidstartHandshake()Start TLS handshake with default parametersvoidstartHandshake(TlsConstants.NamedGroup ecCurve)Start TLS handshake with given parametersvoidstartHandshake(TlsConstants.NamedGroup ecCurve, java.util.List<TlsConstants.SignatureScheme> signatureSchemes)Start TLS handshake with given parameters-
Methods inherited from interface net.luminis.tls.engine.MessageProcessor
received
-
Methods inherited from interface net.luminis.tls.engine.TrafficSecrets
getClientApplicationTrafficSecret, getClientEarlyTrafficSecret, getClientHandshakeTrafficSecret, getServerApplicationTrafficSecret, getServerHandshakeTrafficSecret
-
-
-
-
Method Detail
-
setServerName
void setServerName(java.lang.String serverName)
Set the name of the server that is connected; will be used in the SNI extension.- Parameters:
serverName-
-
addSupportedCiphers
void addSupportedCiphers(java.util.List<TlsConstants.CipherSuite> supportedCiphers)
Adds ciphers to the list of the symmetric cipher options supported by the client (specifically the record protection algorithm (including secret key length) and a hash to be used with HKDF), in descending order of client preference.- Parameters:
supportedCiphers-
-
add
void add(Extension extension)
Adds an extension to the list of extensions to be included in the ClientHello message.- Parameters:
extension-
-
addExtensions
void addExtensions(java.util.List<Extension> extensions)
Adds extensions to the list of extensions to be included in the ClientHello message.- Parameters:
extensions-
-
setTrustManager
void setTrustManager(javax.net.ssl.X509TrustManager customTrustManager)
Sets the trust manager to use for verifying the server certificate. If not set, the default Java trust manager is used.- Parameters:
customTrustManager-
-
setHostnameVerifier
void setHostnameVerifier(HostnameVerifier hostnameVerifier)
Sets the hostname verifier to use for verifying the server name against the server certificate. If not set, the DefaultHostnameVerifier is used, which checks that - the server name equals the CN part of the certificate's subject DN, or - the server name matches one of the dnsName-type "Subject Alternative Name" entries of the certificate.- Parameters:
hostnameVerifier-
-
setNewSessionTicket
void setNewSessionTicket(NewSessionTicket newSessionTicket)
Add ticket to use for a new session. Obviously, this should be done before the handshake is started.- Parameters:
newSessionTicket-
-
setClientCertificateCallback
void setClientCertificateCallback(java.util.function.Function<java.util.List<javax.security.auth.x500.X500Principal>,CertificateWithPrivateKey> callback)
Set the callback to be used for selecting the client certificate (for client authentication).- Parameters:
callback-
-
startHandshake
void startHandshake() throws java.io.IOExceptionStart TLS handshake with default parameters- Throws:
java.io.IOException
-
startHandshake
void startHandshake(TlsConstants.NamedGroup ecCurve) throws java.io.IOException
Start TLS handshake with given parameters- Parameters:
ecCurve- the EC named group to use both for the DHE key generation (and thus for the key share extension) and (as the only supported group) in the supported group extension.- Throws:
java.io.IOException
-
startHandshake
void startHandshake(TlsConstants.NamedGroup ecCurve, java.util.List<TlsConstants.SignatureScheme> signatureSchemes) throws java.io.IOException
Start TLS handshake with given parameters- Parameters:
ecCurve- the EC named group to use both for the DHE key generation (and thus for the key share extension) and (as the only supported group) in the supported group extension.signatureSchemes- the signature algorithms this peer (the client) is willing to accept- Throws:
java.io.IOException
-
handshakeFinished
boolean handshakeFinished()
Returns whether the handshake has (successfully) finished.- Returns:
-
getSelectedCipher
TlsConstants.CipherSuite getSelectedCipher()
Returns the selected (negotiated) cipher suite.- Returns:
-
getNewSessionTickets
java.util.List<NewSessionTicket> getNewSessionTickets()
Returns tickets provided by the current connection.- Returns:
-
getServerCertificateChain
java.util.List<java.security.cert.X509Certificate> getServerCertificateChain()
Returns the server certificate chain.- Returns:
-
setCompatibilityMode
void setCompatibilityMode(boolean compatibilityMode)
Sets the compatibility mode, see https://davidwong.fr/tls13/#appendix-D.4 Only for use in a TLS 1.3 context. Must _not_ be set for QUIC usage, see https://www.rfc-editor.org/rfc/rfc9001.html#name-prohibit-tls-middlebox-com: "A client MUST NOT request the use of the TLS 1.3 compatibility mode."- Parameters:
compatibilityMode-
-
received
void received(ServerHello serverHello, ProtectionKeysType protectedBy) throws MissingExtensionAlert, IllegalParameterAlert
- Specified by:
receivedin interfaceMessageProcessor- Throws:
MissingExtensionAlertIllegalParameterAlert
-
received
void received(EncryptedExtensions encryptedExtensions, ProtectionKeysType protectedBy) throws TlsProtocolException
- Specified by:
receivedin interfaceMessageProcessor- Throws:
TlsProtocolException
-
received
void received(CertificateMessage certificateMessage, ProtectionKeysType protectedBy) throws TlsProtocolException
- Specified by:
receivedin interfaceMessageProcessor- Throws:
TlsProtocolException
-
received
void received(CertificateVerifyMessage certificateVerifyMessage, ProtectionKeysType protectedBy) throws TlsProtocolException
- Specified by:
receivedin interfaceMessageProcessor- Throws:
TlsProtocolException
-
received
void received(FinishedMessage finishedMessage, ProtectionKeysType protectedBy) throws ErrorAlert, java.io.IOException
- Specified by:
receivedin interfaceMessageProcessor- Throws:
ErrorAlertjava.io.IOException
-
received
void received(NewSessionTicketMessage nst, ProtectionKeysType protectedBy) throws UnexpectedMessageAlert
- Specified by:
receivedin interfaceMessageProcessor- Throws:
UnexpectedMessageAlert
-
received
void received(CertificateRequestMessage certificateRequestMessage, ProtectionKeysType protectedBy) throws TlsProtocolException, java.io.IOException
- Specified by:
receivedin interfaceMessageProcessor- Throws:
TlsProtocolExceptionjava.io.IOException
-
-