rustls::server

Trait StoresServerSessions

Source
pub trait StoresServerSessions:
    Debug
    + Send
    + Sync {
    // Required methods
    fn put(&self, key: Vec<u8>, value: Vec<u8>) -> bool;
    fn get(&self, key: &[u8]) -> Option<Vec<u8>>;
    fn take(&self, key: &[u8]) -> Option<Vec<u8>>;
    fn can_cache(&self) -> bool;
}
Expand description

A trait for the ability to store server session data.

The keys and values are opaque.

Both the keys and values should be treated as highly sensitive data, containing enough key material to break all security of the corresponding sessions.

Implementations can be lossy (in other words, forgetting key/value pairs) without any negative security consequences.

However, note that take must reliably delete a returned value. If it does not, there may be security consequences.

put and take are mutating operations; 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 put(&self, key: Vec<u8>, value: Vec<u8>) -> bool

Store session secrets encoded in value against key, overwrites any existing value against key. Returns true if the value was stored.

Source

fn get(&self, key: &[u8]) -> Option<Vec<u8>>

Find a value with the given key. Return it, or None if it doesn’t exist.

Source

fn take(&self, key: &[u8]) -> Option<Vec<u8>>

Find a value with the given key. Return it and delete it; or None if it doesn’t exist.

Source

fn can_cache(&self) -> bool

Whether the store can cache another session. This is used to indicate to clients whether their session can be resumed; the implementation is not required to remember a session even if it returns true here.

Implementors§

Source§

impl StoresServerSessions for NoServerSessionStorage

Source§

impl StoresServerSessions for ServerSessionMemoryCache

Available on crate features std or hashbrown only.