Crate rustls_tokio_postgres

Crate rustls_tokio_postgres 

Source
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::ClientConfig using the native roots of your OS.
  • webpki-roots: enables a helper function for creating a rustls::ClientConfig using the webpki roots.

Re-exports§

pub use rustls;
pub use tokio_postgres;

Structs§

MakeRustlsConnect
A MakeTlsConnect implementation that uses rustls.

Functions§

config_native_rootsnative-roots
Returns a rustls ClientConfig that uses root certificates from the rustls-native-certs crate.
config_no_verify
Returns a rustls ClientConfig that does not verify the server certificate.
config_webpki_rootswebpki-roots
Returns a rustls ClientConfig that uses root certificates from the webpki-roots crate.