Expand description
A tokio_postgres TLS connector backed by rustls.
§Example
use rustls_tokio_postgres::{config_no_verify, MakeRustlsConnect};
use tokio_postgres::{connect, Config};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
static CONFIG: &str = "host=localhost user=postgres";
// This rustls config does not verify the server certificate.
// You can construct your own rustls ClientConfig, or enable the
// `native-roots` or `webpki-roots` features for other config helpers.
let config = config_no_verify();
// Create the client with the TLS configuration.
let tls = MakeRustlsConnect::new(config);
let (_client, _conn) = connect(CONFIG, tls).await?;
Ok(())
}§Features
- channel-binding: enables TLS channel binding, if supported.
- native-roots: enables a helper function for creating a
rustls::ClientConfigusing the native roots of your OS. - webpki-roots: enables a helper function for creating a
rustls::ClientConfigusing the webpki roots.
Re-exports§
pub use rustls;pub use tokio_postgres;
Structs§
- Make
Rustls Connect - A MakeTlsConnect implementation that uses rustls.
Functions§
- config_
native_ roots native-roots - Returns a rustls ClientConfig that uses root certificates from the
rustls-native-certscrate. - config_
no_ verify - Returns a rustls ClientConfig that does not verify the server certificate.
- config_
webpki_ roots webpki-roots - Returns a rustls ClientConfig that uses root certificates from the
webpki-rootscrate.