Skip to main content

TransportConfig

Enum TransportConfig 

Source
pub enum TransportConfig {
    Tls {
        ca_cert_path: Option<String>,
        client_cert_path: Option<String>,
        client_key_path: Option<String>,
        allow_invalid_certificates: bool,
        allow_invalid_hostnames: bool,
    },
    Plaintext,
    RustlsConfig {
        config: RustlsClientConfig,
    },
}
Expand description

Transport configuration for a connector instance.

Variants§

§

Tls

Use TLS transport.

Set ca_cert_path to verify the server against a custom CA bundle; set client_cert_path + client_key_path to enable mutual TLS (mTLS).

Fields

§ca_cert_path: Option<String>

Optional PEM-encoded CA certificate file used to verify the server. When absent the system trust store is used.

§client_cert_path: Option<String>

Optional PEM-encoded client certificate file for mTLS authentication. Must be paired with client_key_path.

§client_key_path: Option<String>

Optional PEM-encoded client private key file for mTLS authentication. Must be paired with client_cert_path.

§allow_invalid_certificates: bool

When true, accept invalid or unknown CA certificates.

This is intended only for local testing or tightly controlled private environments where certificate distribution is not practical.

§allow_invalid_hostnames: bool

When true, skip TLS hostname verification.

This is intended only for local testing or tightly controlled private environments where DNS/SAN validation is not practical.

§

Plaintext

Use plaintext (unencrypted) transport.

§Security Warning

Plaintext transport transmits credentials and data in the clear. Only use this for localhost or fully-trusted private-network deployments (e.g., VPC-internal clusters) where all traffic is already isolated. Do not use plaintext over public or shared networks.

§

RustlsConfig

Use a fully-constructed rustls::ClientConfig injected at runtime.

This variant is intended for advanced use-cases where the caller needs complete control over TLS configuration that cannot be expressed through the file-path-based TransportConfig::Tls variant — for example:

  • Custom certificate verifiers or pinning logic.
  • Client certificates loaded from a hardware security module (HSM).
  • Integration tests that generate ephemeral CA certificates in-process.

Because rustls::ClientConfig is not serializable, this variant serializes as the string "<RustlsClientConfig>" and cannot be round-tripped through a config file. Inject it programmatically only.

Requires the tls Cargo feature.

Fields

§config: RustlsClientConfig

The pre-built rustls client configuration.

Implementations§

Source§

impl TransportConfig

Source

pub fn tls() -> Self

Construct a TLS transport configuration using the system trust store and no client certificate (server-auth-only TLS).

Source

pub fn tls_with_ca_cert_path(ca_cert_path: Option<String>) -> Self

Construct a TLS transport configuration with an optional CA bundle.

Source

pub fn mtls( ca_cert_path: Option<String>, client_cert_path: String, client_key_path: String, ) -> Self

Construct a mutual TLS (mTLS) configuration.

Both client_cert_path and client_key_path are required. ca_cert_path is optional and falls back to the system trust store.

Source

pub fn tls_insecure_skip_verify() -> Self

Construct TLS transport that skips certificate and hostname validation.

Use only for local testing or tightly controlled private environments.

Source

pub const fn plaintext() -> Self

Construct a plaintext (unencrypted) transport configuration.

See the TransportConfig::Plaintext variant for security guidance.

Source

pub fn rustls_config(config: Arc<ClientConfig>) -> Self

Inject a pre-built rustls::ClientConfig directly.

Use this when the file-path-based TransportConfig::Tls variant does not provide the level of control you need (custom verifiers, HSM keys, ephemeral in-process CAs, etc.).

Requires the tls Cargo feature.

Source

pub fn is_tls(&self) -> bool

Return true when TLS transport is configured.

Source

pub fn is_mtls(&self) -> bool

Return true when mutual TLS (mTLS) is configured (client cert + key both set).

Source

pub fn ca_cert_path(&self) -> Option<&str>

Return the configured CA bundle path, if any.

Source

pub fn allow_invalid_certificates(&self) -> bool

Return true when TLS certificate verification is disabled.

Always returns false for TransportConfig::RustlsConfig — the injected ClientConfig is assumed to already encode the desired verification policy.

Source

pub fn allow_invalid_hostnames(&self) -> bool

Return true when TLS hostname verification is disabled.

Always returns false for TransportConfig::RustlsConfig — the injected ClientConfig is assumed to already encode the desired hostname policy.

Source

pub fn client_cert_path(&self) -> Option<&str>

Return the configured client certificate path, if any.

Source

pub fn client_key_path(&self) -> Option<&str>

Return the configured client private key path, if any.

Source

pub fn warn_if_insecure(&self, source_label: &str)

Emit tracing::warn! events for any insecure TLS flags.

Call this once per connection attempt. When allow_invalid_certificates or allow_invalid_hostnames is set, a structured warning is emitted so that log-aggregation pipelines and alerting rules can detect accidental production use of insecure TLS configuration.

Trait Implementations§

Source§

impl Clone for TransportConfig

Source§

fn clone(&self) -> TransportConfig

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 TransportConfig

Source§

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

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

impl Default for TransportConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for TransportConfig

Source§

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

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for TransportConfig

Source§

impl PartialEq for TransportConfig

Source§

fn eq(&self, other: &TransportConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TransportConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TransportConfig

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> 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> 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.
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