Crate yb_postgres_native_tls

source
Expand description

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 = yb_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 = yb_postgres::Client::connect(
    "host=localhost user=postgres sslmode=require",
    connector,
)?;

Structs§

  • A MakeTlsConnect implementation using the native-tls crate.
  • A TlsConnect implementation using the native-tls crate.
  • The stream returned by TlsConnector.