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:
- Return
falsefromaccepts_invalid_certsunless explicitly configured otherwise by the user. Certificate validation bypass (CWE-295) should never be the default. - Return
TlsVersion::Tls12or higher frommin_tls_version. TLS 1.0 and 1.1 are deprecated (RFC 8996). - Emit an
ExtensionWarningviaWarningCollectorwhen certificate validation is disabled or when using a TLS version below 1.2.
§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§
- TlsConfig
Provider - A type-erased provider of TLS client configuration.
Functions§
- audit_
tls_ provider - Validates a
TlsConfigProviderand returns a list of security concerns.