Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tokio-postgres/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ pub enum SslMode {
Prefer,
/// Require the use of TLS.
Require,
/// Require the use of TLS. Verify peer cert without hostname verification.
/// The user of this lib must handle TLS verification and set ssl mode to Require before calling `connect_tls`.
VerifyCa,
/// Require the use of TLS. Verify peer cert and hostname.
/// The user of this lib must handle TLS verification and set ssl mode to Require before calling `connect_tls`.
VerifyFull,
}

/// Channel binding configuration.
Expand Down Expand Up @@ -446,6 +452,8 @@ impl Config {
"disable" => SslMode::Disable,
"prefer" => SslMode::Prefer,
"require" => SslMode::Require,
"verify-ca" => SslMode::VerifyCa,
"verify-full" => SslMode::VerifyFull,
_ => return Err(Error::config_parse(Box::new(InvalidValue("sslmode")))),
};
self.ssl_mode(mode);
Expand Down
5 changes: 5 additions & 0 deletions tokio-postgres/src/connect_tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ where
return Ok(MaybeTlsStream::Raw(stream))
}
SslMode::Prefer | SslMode::Require => {}
SslMode::VerifyCa | SslMode::VerifyFull => {
// The user of this lib must handle TLS verification themselves
// and set config ssl mode to Require before calling connect_tls()
return Err(Error::tls("TLS verification was not handled".into()));
}
}

let mut buf = BytesMut::new();
Expand Down