跳到主要内容

ClientSessionStore

特性 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>;
}
展开描述

A trait 用于 the ability 到 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 密钥材料 到 break all security of the corresponding session.

set_, insert_, remove_take_ operations are mutating; this isn’t expressed in the type system 到 allow implementations freedom in how 到 achieve interior mutability. Mutex 是 common choice.

必需方法§

Source

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

记住 NamedGroup 给定服务器选择的

Source

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

This should return the value most recently passed 到 set_kx_hint 用于 the given server_name

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

Source

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

Remember 一个 TLS1.2 session.

At most one of these can be remembered at 一个 time, per server_name

Source

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

获取最近保存的 TLS1.2 session 用于 server_name provided 到 set_tls12_session

Source

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

移除并忘记已保存的 TLS1.2 session 用于 server_name

Source

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

Remember 一个 TLS 1.3 ticket that might be retrieved later 从 take_tls13_ticket, allowing resumption of this session.

This can be called multiple times 用于 一个 given session, allowing multiple independent tickets 到 be valid at once. 此 number of times this is called is controlled by the server, so implementations of this trait should apply 一个 reasonable bound of how many items are stored simultaneously.

Source

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

Return 一个 TLS 1.3 ticket previously provided 到 add_tls13_ticket

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

实现者§