Skip to main content

TlsManager

Struct TlsManager 

Source
pub struct TlsManager { /* private fields */ }
Expand description

Manages TLS configuration for the proxy, supporting both automatic ACME certificate issuance (via certon) and manually-provided PEM certificates.

The manager builds a rustls::ServerConfig that uses a composite certificate resolver:

  • Sites with explicit SiteTlsConfig (cert/key PEM paths) are loaded immediately and registered as manual overrides.
  • Sites without explicit certs are enrolled in ACME management through certon, which obtains, caches, and auto-renews their certificates.

Additionally supports:

  • mTLS (mutual TLS): client certificate verification using configured CA certificates. When client_auth is configured, the server requests (and optionally requires) client certificates.
  • On-demand TLS: automatic certificate issuance at handshake time for previously unknown domains, with optional ask-URL gating and rate limiting.

Call TlsManager::reload to hot-swap the TLS configuration when the proxy config changes.

Implementations§

Source§

impl TlsManager

Source

pub async fn build(config: &AppConfig) -> Result<Self, ProxyError>

Build a new TlsManager from the application configuration.

This performs the initial TLS setup:

  1. Loads manual certificates for sites that specify cert/key paths.
  2. Configures certon for ACME-managed sites (if ACME is enabled).
  3. Calls manage_sync to obtain/load certificates for ACME domains.
  4. Starts the certon maintenance loop.
  5. Sets up mTLS client certificate verification if configured.
  6. Configures on-demand TLS if configured.
§Errors

Returns an error if manual certificate loading fails or if ACME management cannot be initialized.

Source

pub fn acceptor(&self) -> TlsAcceptor

Get a TlsAcceptor for use with tokio-rustls.

The returned acceptor references the current ServerConfig via an Arc, so it will continue to use the config snapshot at the time of this call. For hot-reload, call this again after reload.

Source

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

Get the current rustls::ServerConfig as an Arc.

Source

pub fn challenge_map(&self) -> Arc<RwLock<HashMap<String, String>>>

Get a reference to the shared ACME HTTP-01 challenge map.

This is the same map that the AcmeChallengeHoop reads from to serve challenge responses.

Source

pub async fn reload(&self, config: &AppConfig) -> Result<(), ProxyError>

Hot-reload the TLS configuration.

This rebuilds manual certificates and re-enrolls ACME domains based on the new config. The ServerConfig is atomically swapped so that in-flight connections are not affected.

§Errors

Returns an error if any manual certificate cannot be loaded.

Source

pub fn stop_maintenance(&self)

Stop the certon maintenance loop.

This should be called during graceful shutdown. After calling this, no further certificate renewals or OCSP refreshes will occur.

Trait Implementations§

Source§

impl Drop for TlsManager

Source§

fn drop(&mut self)

Executes the destructor for this type. 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more