A pure-Rust frontend for the popular PostgreSQL database.
extern crate postgres;
use ;
SSL/TLS
This crate supports TLS secured connections. The TlsMode
enum is passed to connection methods
and indicates if the connection will not, may, or must be secured by TLS. The TLS implementation
is pluggable through the TlsHandshake
trait. Implementations for OpenSSL, Secure Transport,
SChannel, and the native-tls
crate are provided behind the with-openssl
,
with-security-framework
, with-schannel
, and with-native-tls
feature flags respectively.
Examples
Connecting using native-tls
:
extern crate postgres;
use postgres::{Connection, TlsMode};
# #[cfg(feature = "with-native-tls")]
use postgres::tls::native_tls::NativeTls;
# #[cfg(not(feature = "with-native-tls"))] fn main() {}
# #[cfg(feature = "with-native-tls")]
fn main() {
let negotiator = NativeTls::new().unwrap();
let conn = Connection::connect("postgres://postgres@localhost:5433", TlsMode::Require(&negotiator))
.unwrap();
}