8 releases (4 breaking)
0.5.0 | Dec 25, 2020 |
---|---|
0.4.0 | Oct 17, 2020 |
0.3.0 | Dec 24, 2019 |
0.3.0-alpha.2 | Nov 28, 2019 |
0.1.0-rc.1 | Jun 30, 2019 |
#1370 in Database interfaces
41,481 downloads per month
Used in 46 crates
(35 directly)
280KB
6K
SLoC
TLS support for tokio-postgres
and postgres
via native-tls
.
Examples
use native_tls::{Certificate, TlsConnector};
use postgres_native_tls::MakeTlsConnector;
use std::fs;
let cert = fs::read("database_cert.pem")?;
let cert = Certificate::from_pem(&cert)?;
let connector = TlsConnector::builder()
.add_root_certificate(cert)
.build()?;
let connector = MakeTlsConnector::new(connector);
let connect_future = tokio_postgres::connect(
"host=localhost user=postgres sslmode=require",
connector,
);
// ...
use native_tls::{Certificate, TlsConnector};
use postgres_native_tls::MakeTlsConnector;
use std::fs;
let cert = fs::read("database_cert.pem")?;
let cert = Certificate::from_pem(&cert)?;
let connector = TlsConnector::builder()
.add_root_certificate(cert)
.build()?;
let connector = MakeTlsConnector::new(connector);
let client = postgres::Client::connect(
"host=localhost user=postgres sslmode=require",
connector,
)?;
Dependencies
~7–18MB
~270K SLoC