Skip to main content

Tls

Struct Tls 

Source
pub struct Tls { /* private fields */ }
Available on crate feature tls only.
Expand description

A loaded TLS configuration: a certificate chain, a private key, and either a client-certificate verifier or the absence of one.

Built by Tls::load during Server::start, so a key that cannot be read, a key with permissions that make it not a secret, and a certificate that does not match it are all startup refusals rather than the first connection’s problem.

Implementations§

Source§

impl Tls

Source

pub fn load(config: &TlsConfig) -> Result<Self, TlsError>

Reads the certificate, the key and — if one is configured — the client CA, and builds the rustls configuration from them.

§Errors

A TlsError naming the file and the fix. None of them carries a byte of the key: see TlsError.

Source

pub fn server_config(&self) -> Arc<ServerConfig>

The rustls configuration, for the acceptor.

Source

pub fn is_mutual(&self) -> bool

Whether a client certificate is required.

True exactly when client_ca was configured: there is no third state in which a certificate is asked for and not required.

Trait Implementations§

Source§

impl Debug for Tls

Hand-written, and the reason is the same one AGENTS.md records for tokens: this type holds a private key, and a derive prints every field. Two booleans is everything a debugger needs from it.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Tls

§

impl !UnwindSafe for Tls

§

impl Freeze for Tls

§

impl Send for Tls

§

impl Sync for Tls

§

impl Unpin for Tls

§

impl UnsafeUnpin for Tls

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.