Skip to main content

Module tls

Module tls 

Source
Expand description

Type-erased TLS configuration provider for HTTP-capable extensions.

Extensions that make outbound HTTPS connections (e.g., duck_net) need a way to inject custom TLS configurations — client certificates for mTLS, custom CA bundles, or restricted cipher suites. This module provides the TlsConfigProvider trait so that extensions can supply their TLS setup through a uniform interface, regardless of which TLS library they use.

§Design

The trait is type-erased via std::any::Any so that quack-rs does not depend on any specific TLS library (e.g., rustls, native-tls). The implementing extension downcasts the returned Arc<dyn Any> to its concrete config type.

§Security requirements for implementors

Implementations must:

§Example

use quack_rs::tls::{TlsConfigProvider, TlsVersion};
use quack_rs::error::ExtensionError;
use std::any::Any;
use std::sync::Arc;

struct MyTlsProvider {
    // In practice: Arc<rustls::ClientConfig>
    config: Arc<String>,
    mtls_enabled: bool,
}

impl TlsConfigProvider for MyTlsProvider {
    fn client_config(&self) -> Result<Arc<dyn Any + Send + Sync>, ExtensionError> {
        Ok(self.config.clone())
    }

    fn provider_name(&self) -> &str {
        "my-extension-tls"
    }

    fn config_type_name(&self) -> &str {
        "String" // In practice: "rustls::ClientConfig"
    }

    fn min_tls_version(&self) -> TlsVersion {
        TlsVersion::Tls12
    }

    fn supports_mtls(&self) -> bool {
        self.mtls_enabled
    }

    fn accepts_invalid_certs(&self) -> bool {
        false
    }
}

Enums§

TlsVersion
Minimum TLS protocol version supported by a TlsConfigProvider.

Traits§

TlsConfigProvider
A type-erased provider of TLS client configuration.

Functions§

audit_tls_provider
Validates a TlsConfigProvider and returns a list of security concerns.