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 = 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,
)?;Structs§
- Make
TlsConnector - A
MakeTlsConnectimplementation using thenative-tlscrate. - TlsConnector
- A
TlsConnectimplementation using thenative-tlscrate. - TlsStream
- The stream returned by
TlsConnector.
Functions§
- set_
postgresql_ alpn - Set ALPN for
TlsConnectorBuilder