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

#1317 in Database interfaces

Download history 13461/week @ 2024-07-19 15100/week @ 2024-07-26 12286/week @ 2024-08-02 13574/week @ 2024-08-09 13765/week @ 2024-08-16 16958/week @ 2024-08-23 15082/week @ 2024-08-30 16160/week @ 2024-09-06 15813/week @ 2024-09-13 19378/week @ 2024-09-20 19680/week @ 2024-09-27 18946/week @ 2024-10-04 18985/week @ 2024-10-11 20556/week @ 2024-10-18 24249/week @ 2024-10-25 25806/week @ 2024-11-01

93,714 downloads per month
Used in 50 crates (37 directly)

MIT/Apache

290KB
6.5K 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
~271K SLoC