pub struct ClientConnection { /* private fields */ }Expand description
This represents a single TLS client connection.
Implementations§
Source§impl ClientConnection
impl ClientConnection
Sourcepub fn early_data(&mut self) -> Option<WriteEarlyData<'_>>
pub fn early_data(&mut self) -> Option<WriteEarlyData<'_>>
Returns an io::Write implementer you can write bytes to
to send TLS1.3 early data (a.k.a. “0-RTT data”) to the server.
This returns None in many circumstances when the capability to send early data is not available, including but not limited to:
- The server hasn’t been talked to previously.
- The server does not support resumption.
- The server does not support early data.
- The resumption data for the server has expired.
The server specifies a maximum amount of early data. You can learn this limit through the returned object, and writes through it will process only this many bytes.
The server can choose not to accept any sent early data –
in this case the data is lost but the connection continues. You
can tell this happened using is_early_data_accepted.
Sourcepub fn is_early_data_accepted(&self) -> bool
pub fn is_early_data_accepted(&self) -> bool
Returns True if the server signalled it will process early data.
If you sent early data and this returns false at the end of the handshake then the server will not process the data. This is not an error, but you may wish to resend the data.
Sourcepub fn dangerous_extract_secrets(self) -> Result<ExtractedSecrets, Error>
pub fn dangerous_extract_secrets(self) -> Result<ExtractedSecrets, Error>
Extract secrets, so they can be used when configuring kTLS, for example. Should be used with care as it exposes secret key material.
Sourcepub fn ech_status(&self) -> EchStatus
pub fn ech_status(&self) -> EchStatus
Return the connection’s Encrypted Client Hello (ECH) status.
Sourcepub fn tls13_tickets_received(&self) -> u32
pub fn tls13_tickets_received(&self) -> u32
Returns the number of TLS1.3 tickets that have been received.
Methods from Deref<Target = ConnectionOutputs>§
Sourcepub fn peer_identity(&self) -> Option<&Identity<'static>>
pub fn peer_identity(&self) -> Option<&Identity<'static>>
Retrieves the certificate chain or the raw public key used by the peer to authenticate.
This is made available for both full and resumed handshakes.
For clients, this is the identity of the server. For servers, this is the identity of the client, if client authentication was completed.
The return value is None until this value is available.
Sourcepub fn alpn_protocol(&self) -> Option<&ApplicationProtocol<'static>>
pub fn alpn_protocol(&self) -> Option<&ApplicationProtocol<'static>>
Retrieves the protocol agreed with the peer via ALPN.
A return value of None after handshake completion
means no protocol was agreed (because no protocols
were offered or accepted by the peer).
Sourcepub fn negotiated_cipher_suite(&self) -> Option<SupportedCipherSuite>
pub fn negotiated_cipher_suite(&self) -> Option<SupportedCipherSuite>
Retrieves the cipher suite agreed with the peer.
This returns None until the cipher suite is agreed.
Sourcepub fn negotiated_key_exchange_group(
&self,
) -> Option<&'static dyn SupportedKxGroup>
pub fn negotiated_key_exchange_group( &self, ) -> Option<&'static dyn SupportedKxGroup>
Retrieves the key exchange group agreed with the peer.
This function may return None depending on the state of the connection,
the type of handshake, and the protocol version.
If CommonState::is_handshaking() is true this function will return None.
Similarly, if the ConnectionOutputs::handshake_kind() is HandshakeKind::Resumed
and the ConnectionOutputs::protocol_version() is TLS 1.2, then no key exchange will have
occurred and this function will return None.
Sourcepub fn protocol_version(&self) -> Option<ProtocolVersion>
pub fn protocol_version(&self) -> Option<ProtocolVersion>
Retrieves the protocol version agreed with the peer.
This returns None until the version is agreed.
Sourcepub fn handshake_kind(&self) -> Option<HandshakeKind>
pub fn handshake_kind(&self) -> Option<HandshakeKind>
Which kind of handshake was performed.
This tells you whether the handshake was a resumption or not.
This will return None before it is known which sort of
handshake occurred.
Trait Implementations§
Source§impl Connection for ClientConnection
impl Connection for ClientConnection
Source§fn read_tls(&mut self, rd: &mut dyn Read) -> Result<usize, Error>
fn read_tls(&mut self, rd: &mut dyn Read) -> Result<usize, Error>
rd into the internal buffer. Read moreSource§fn write_tls(&mut self, wr: &mut dyn Write) -> Result<usize, Error>
fn write_tls(&mut self, wr: &mut dyn Write) -> Result<usize, Error>
wr. Read moreSource§fn wants_read(&self) -> bool
fn wants_read(&self) -> bool
Connection::read_tls as soon
as possible. Read moreSource§fn wants_write(&self) -> bool
fn wants_write(&self) -> bool
Connection::write_tls as soon as possible.Source§fn process_new_packets(&mut self) -> Result<IoState, Error>
fn process_new_packets(&mut self) -> Result<IoState, Error>
Connection::read_tls. Read moreSource§fn exporter(&mut self) -> Result<KeyingMaterialExporter, Error>
fn exporter(&mut self) -> Result<KeyingMaterialExporter, Error>
Source§fn dangerous_extract_secrets(self) -> Result<ExtractedSecrets, Error>
fn dangerous_extract_secrets(self) -> Result<ExtractedSecrets, Error>
Source§fn set_buffer_limit(&mut self, limit: Option<usize>)
fn set_buffer_limit(&mut self, limit: Option<usize>)
Connection::writer. Read moreSource§fn set_plaintext_buffer_limit(&mut self, limit: Option<usize>)
fn set_plaintext_buffer_limit(&mut self, limit: Option<usize>)
Source§fn refresh_traffic_keys(&mut self) -> Result<(), Error>
fn refresh_traffic_keys(&mut self) -> Result<(), Error>
key_update message to refresh a connection’s keys. Read moreSource§fn send_close_notify(&mut self)
fn send_close_notify(&mut self)
close_notify warning alert to be sent in the next
Connection::write_tls call. This informs the peer that the
connection is being closed. Read more