pub enum TlsMode {
Disabled,
Rustls(Arc<ClientConfig>),
}Expand description
TLS mode to use when connecting to PostgreSQL.
Variants§
Disabled
Plain-text connection — no encryption.
Rustls(Arc<ClientConfig>)
TLS via a pre-built rustls ClientConfig sourced from OxiTLS.
Build the config using, e.g.:
let cfg = oxitls::client_config(oxitls::webpki_root_certs())?;
let tls = oxisql_postgres::TlsMode::Rustls(cfg);Implementations§
Source§impl TlsMode
impl TlsMode
Sourcepub fn skip_verify() -> Result<Self, PgError>
pub fn skip_verify() -> Result<Self, PgError>
Build a TlsMode::Rustls that skips server certificate verification.
§Security Warning
This mode accepts any server certificate, including self-signed and expired ones. It is vulnerable to man-in-the-middle attacks. Only use this in development or testing environments.
§Errors
Returns PgError::Tls if the rustls ClientConfig cannot be built.
Sourcepub fn with_ca_pem(ca_pem: Vec<u8>) -> Result<Self, PgError>
pub fn with_ca_pem(ca_pem: Vec<u8>) -> Result<Self, PgError>
Build a TlsMode::Rustls that trusts a custom CA certificate in PEM
format, in addition to the system/WebPKI root store.
ca_pem must contain one or more PEM-encoded X.509 certificates.
§Errors
Returns PgError::Tls if the PEM cannot be parsed or the
rustls ClientConfig cannot be built.