pub struct TlsState { /* private fields */ }Expand description
Reloadable TLS state (v0.3 #10). Wraps an ArcSwap<ServerConfig> so the
listener can swap the cert/key pair atomically on SIGHUP without dropping
any in-flight connections. Construct via TlsState::load and pass
Arc<TlsState> to both the accept loop and the SIGHUP handler.
Implementations§
Source§impl TlsState
impl TlsState
Sourcepub fn load(
cert_path: impl Into<PathBuf>,
key_path: impl Into<PathBuf>,
) -> Result<Self, Box<dyn Error + Send + Sync + 'static>>
pub fn load( cert_path: impl Into<PathBuf>, key_path: impl Into<PathBuf>, ) -> Result<Self, Box<dyn Error + Send + Sync + 'static>>
Initial load — fails on parse error. Accepts TLS 1.2 + 1.3.
Sourcepub fn load_tls13_only(
cert_path: impl Into<PathBuf>,
key_path: impl Into<PathBuf>,
) -> Result<Self, Box<dyn Error + Send + Sync + 'static>>
pub fn load_tls13_only( cert_path: impl Into<PathBuf>, key_path: impl Into<PathBuf>, ) -> Result<Self, Box<dyn Error + Send + Sync + 'static>>
v0.5 #32: TLS 1.3-only initial load — fails on parse error.
Reloads via Self::reload also use the 1.3-only loader, so a
SIGHUP hot-swap can’t accidentally re-enable 1.2.
Sourcepub fn acceptor(&self) -> TlsAcceptor
pub fn acceptor(&self) -> TlsAcceptor
Build a fresh TlsAcceptor from the current config. Cheap (one
atomic load + Arc clone). Call this once per accepted connection.
Sourcepub fn reload(&self) -> Result<(), Box<dyn Error + Send + Sync + 'static>>
pub fn reload(&self) -> Result<(), Box<dyn Error + Send + Sync + 'static>>
Re-read the cert + key from disk and atomically swap the active
config. Returns Ok(()) on success and Err(...) if the new pair
failed to parse — the previous config remains in effect either way,
so a bad reload never causes a listener outage.