Crate opengauss_native_tls
source ·Expand description
TLS support for tokio-postgres
and postgres
via native-tls
.
Examples
use native_tls::{Certificate, TlsConnector};
use opengauss_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_opengauss::connect(
"host=localhost user=postgres password=openGauss#2023 sslmode=require",
connector,
);
// ...
use native_tls::{Certificate, TlsConnector};
use opengauss_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 = opengauss::Client::connect(
"host=localhost user=postgres password=openGauss#2023 sslmode=require",
connector,
)?;
Structs
- A
MakeTlsConnect
implementation using thenative-tls
crate. - A
TlsConnect
implementation using thenative-tls
crate. - The stream returned by
TlsConnector
.