Skip to main content

TlsConfig

Struct TlsConfig 

Source
pub struct TlsConfig {
    pub certificate: String,
    pub key: String,
    pub client_ca: Option<String>,
    pub crl: Option<String>,
}
Expand description

Where the server’s own certificate, key and client CA live.

Its presence is what turns TLS on; there is no enabled key, because a block that names a certificate and does nothing is a deployment that believes it is encrypted and is not.

[server.tls]
certificate = "/etc/dynamic-config/server.pem"
key = "/etc/dynamic-config/server.key"
client_ca = "/etc/dynamic-config/clients-ca.pem"   # optional; see below

Only paths live here. The key’s bytes are read once, at startup, by Tls::load, and never reach a diagnostic — see TlsError.

Fields§

§certificate: String

PEM holding the server’s certificate, then any intermediates, leaf first.

§key: String

PEM holding that certificate’s private key: PKCS#8, PKCS#1 or SEC1.

On Unix the server refuses to start if this file is readable by anything but its owner, for the same reason it refuses a token under 32 characters.

§client_ca: Option<String>

PEM holding the certificate authority every client certificate must chain to.

Present means mutual TLS is required: a caller that presents no certificate, or one signed by anything else, does not complete the handshake and never becomes a request. Absent means the server authenticates itself to callers and asks for nothing back.

A certificate is a second gate, never a second identity: it is not an alternative to the bearer token and it does not name a caller. See the tls module.

No revocation is checked. A certificate that chains here is good until it expires; see crl.

§crl: Option<String>

A certificate revocation list — a startup refusal, never a file this server reads.

The key exists so that an operator who reaches for revocation is told that this server does not check it, rather than being told unknown field 'crl' and going looking for a different spelling. It is the same reason tls itself is parsed in a build without the feature: a security-relevant key that reads as a typo is worse than one that reads as a decision.

The decision, and it was measured rather than assumed (RevocationUnsupported’s message is the short form): rustls will accept a CRL whose nextUpdate passed years ago without a word, because ExpirationPolicy::Ignore is the default — so the twenty lines that look like revocation are a check that stops being true the moment the file stops being refreshed, with nothing anywhere reporting it. The one switch that refuses a stale list, enforce_revocation_expiration, refuses every client while it is stale, which turns a CRL publishing hiccup into a fleet-wide configuration outage. Neither is a posture this crate will ship, and a file watcher does not rescue it: the failure to catch is the absence of a write, and no filesystem event fires for that.

What to do instead is in tls: short-lived client certificates, and revoke the bearer token — the credential that actually authorises, and the one this server can withdraw by removing a line.

Trait Implementations§

Source§

impl Clone for TlsConfig

Source§

fn clone(&self) -> TlsConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TlsConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TlsConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.