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

Download history 10678/week @ 2024-03-14 9584/week @ 2024-03-21 10539/week @ 2024-03-28 10771/week @ 2024-04-04 9866/week @ 2024-04-11 10560/week @ 2024-04-18 10846/week @ 2024-04-25 8690/week @ 2024-05-02 9873/week @ 2024-05-09 9990/week @ 2024-05-16 9254/week @ 2024-05-23 10218/week @ 2024-05-30 9546/week @ 2024-06-06 11229/week @ 2024-06-13 11345/week @ 2024-06-20 7553/week @ 2024-06-27

41,481 downloads per month
Used in 46 crates (35 directly)

MIT/Apache

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