pub struct PostgresTlsConfig {
pub mode: Option<PostgresSslMode>,
pub ca_bundle_path: Option<PathBuf>,
}Expand description
Transport security settings for a PostgreSQL connection pool.
Fields§
§mode: Option<PostgresSslMode>How much transport security to demand, or None to let the connection URL
decide.
None is not the same as Some(Prefer). An unset mode leaves the driver to
read ?sslmode= out of the URL; forcing Prefer in its place would
override an operator’s explicit ?sslmode=require and silently downgrade
it to opportunistic encryption. The URL form was the one surface that already
failed loudly here, so a config default must not be allowed to quietly
outrank it.
ca_bundle_path: Option<PathBuf>PEM bundle of certificate authorities to trust when verifying the server.
When set, these roots replace the platform trust store rather than adding to it — a managed-database CA (RDS, Cloud SQL) is normally not in the system store, and an operator who names a CA file means “this CA”, not “this CA or any of the several hundred the OS ships”.
Only consulted by PostgresSslMode::VerifyFull; the weaker modes verify
nothing, so supplying a bundle alongside them is rejected by
validate rather than silently ignored.
Implementations§
Source§impl PostgresTlsConfig
impl PostgresTlsConfig
Sourcepub const fn new(mode: PostgresSslMode) -> PostgresTlsConfig
pub const fn new(mode: PostgresSslMode) -> PostgresTlsConfig
Settings that explicitly demand mode, using the platform trust store.
Sourcepub fn effective_mode(&self) -> PostgresSslMode
pub fn effective_mode(&self) -> PostgresSslMode
The mode the connector should enforce, treating “unset” as libpq’s default.
Used to decide verification, which must be settled before the handshake.
An unset mode cannot be verify-full, because the only thing that could have
set it is the URL and ?sslmode= tops out at require.
Sourcepub fn validate(&self) -> Result<(), FraiseQLError>
pub fn validate(&self) -> Result<(), FraiseQLError>
Reject combinations whose parts contradict each other.
§Errors
Returns FraiseQLError::Configuration when a CA bundle is supplied for a
mode that never verifies a certificate. Accepting it would leave the
operator believing the named CA was pinned while the connection
authenticated nothing — the shape of defect this module exists to remove.
Sourcepub fn warn_if_unverified(&self)
pub fn warn_if_unverified(&self)
Emit a startup warning when the configured mode encrypts without authenticating the peer.
Scoped to require, which is the mode an operator chooses in order to get
transport security and which therefore carries the false confidence:
“encrypted” and “encrypted to the right server” are the two things most
easily conflated, so the boot log separates them. prefer is the default and
promises nothing, so warning on it would be noise on every boot.
Sourcepub fn connector(&self) -> Result<PostgresConnector, FraiseQLError>
pub fn connector(&self) -> Result<PostgresConnector, FraiseQLError>
Build the connector deadpool should create connections with.
§Errors
Returns FraiseQLError::Configuration if the settings contradict
themselves, if the CA bundle cannot be read or contains no usable
certificate, or if no trust anchors are available for a verifying mode.
Trait Implementations§
Source§impl Clone for PostgresTlsConfig
impl Clone for PostgresTlsConfig
Source§fn clone(&self) -> PostgresTlsConfig
fn clone(&self) -> PostgresTlsConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PostgresTlsConfig
impl Debug for PostgresTlsConfig
Source§impl Default for PostgresTlsConfig
impl Default for PostgresTlsConfig
Source§fn default() -> PostgresTlsConfig
fn default() -> PostgresTlsConfig
impl Eq for PostgresTlsConfig
Source§impl PartialEq for PostgresTlsConfig
impl PartialEq for PostgresTlsConfig
impl StructuralPartialEq for PostgresTlsConfig
Auto Trait Implementations§
impl Freeze for PostgresTlsConfig
impl RefUnwindSafe for PostgresTlsConfig
impl Send for PostgresTlsConfig
impl Sync for PostgresTlsConfig
impl Unpin for PostgresTlsConfig
impl UnsafeUnpin for PostgresTlsConfig
impl UnwindSafe for PostgresTlsConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.