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

#1321 in Database interfaces

Download history 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 25818/week @ 2024-11-01 23373/week @ 2024-11-08 26973/week @ 2024-11-15 23461/week @ 2024-11-22 22775/week @ 2024-11-29 24505/week @ 2024-12-06 23529/week @ 2024-12-13 13721/week @ 2024-12-20 10905/week @ 2024-12-27 14872/week @ 2025-01-03

66,810 downloads per month
Used in 51 crates (38 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
~279K SLoC