rustls::client

Trait ClientSessionStore

source
pub trait ClientSessionStore:
    Debug
    + Send
    + Sync {
    // Required methods
    fn set_kx_hint(&self, server_name: ServerName<'static>, group: NamedGroup);
    fn kx_hint(&self, server_name: &ServerName<'_>) -> Option<NamedGroup>;
    fn set_tls12_session(
        &self,
        server_name: ServerName<'static>,
        value: Tls12ClientSessionValue,
    );
    fn tls12_session(
        &self,
        server_name: &ServerName<'_>,
    ) -> Option<Tls12ClientSessionValue>;
    fn remove_tls12_session(&self, server_name: &ServerName<'static>);
    fn insert_tls13_ticket(
        &self,
        server_name: ServerName<'static>,
        value: Tls13ClientSessionValue,
    );
    fn take_tls13_ticket(
        &self,
        server_name: &ServerName<'static>,
    ) -> Option<Tls13ClientSessionValue>;
}
Expand description

A trait for the ability to store client session data, so that sessions can be resumed in future connections.

Generally all data in this interface should be treated as highly sensitive, containing enough key material to break all security of the corresponding session.

set_, insert_, remove_ and take_ operations are mutating; this isn’t expressed in the type system to allow implementations freedom in how to achieve interior mutability. Mutex is a common choice.

Required Methods§

source

fn set_kx_hint(&self, server_name: ServerName<'static>, group: NamedGroup)

Remember what NamedGroup the given server chose.

source

fn kx_hint(&self, server_name: &ServerName<'_>) -> Option<NamedGroup>

This should return the value most recently passed to set_kx_hint for the given server_name.

If None is returned, the caller chooses the first configured group, and an extra round trip might happen if that choice is unsatisfactory to the server.

source

fn set_tls12_session( &self, server_name: ServerName<'static>, value: Tls12ClientSessionValue, )

Remember a TLS1.2 session.

At most one of these can be remembered at a time, per server_name.

source

fn tls12_session( &self, server_name: &ServerName<'_>, ) -> Option<Tls12ClientSessionValue>

Get the most recently saved TLS1.2 session for server_name provided to set_tls12_session.

source

fn remove_tls12_session(&self, server_name: &ServerName<'static>)

Remove and forget any saved TLS1.2 session for server_name.

source

fn insert_tls13_ticket( &self, server_name: ServerName<'static>, value: Tls13ClientSessionValue, )

Remember a TLS1.3 ticket that might be retrieved later from take_tls13_ticket, allowing resumption of this session.

This can be called multiple times for a given session, allowing multiple independent tickets to be valid at once. The number of times this is called is controlled by the server, so implementations of this trait should apply a reasonable bound of how many items are stored simultaneously.

source

fn take_tls13_ticket( &self, server_name: &ServerName<'static>, ) -> Option<Tls13ClientSessionValue>

Return a TLS1.3 ticket previously provided to add_tls13_ticket.

Implementations of this trait must return each value provided to add_tls13_ticket at most once.

Implementors§