tokio-postgres-rustls
NOTE: This is a fork; the original tokio-postgres-rustls repo appears to be unmaintained and has known bugs with virtually no test coverage or CI pipeline.
Improvements over original tokio-postgres-rustls
:
- Removed unsafe code (thanks @conradludgate)
- Fixes SCRAM/SASL channel binding
- Add support for
aws-lc-rs
instead ofring
(defaults toaws-lc-rs
; consistent withrustls
defaults) - Added comprehensive integration test suite that runs with both
ring
andaws-lc-rs
This is an integration between the rustls TLS stack and the tokio-postgres asynchronous PostgreSQL client library.
Use this crate directly:
With aws-lc-rs
(default for rustls
):
With ring
:
Have a 3rd-party dependency that relies on the original tokio-postgres-rustls
?
Patch in our fork that maintains the original crate name like this:
[]
= { = "https://github.com/khorsolutions/tokio-postgres-rustls.git", = "0.15.0" }
Please note that backports to this repo are not currently automated, so using tokio-postgres-rustls-improved
is preferred when possible.
Example
See tests/integration.rs
for actual usage examples, including SASL/SCRAM using Channel Binding.
// Setup a `rustls::ClientConfig` (see Rustls docs for more info)
let tls_config = builder
.with_root_certificates
.with_client_auth_cert
.expect;
// MakeRustlsConnect is provided by this library; it wraps a `rustls::CLientConfig`
let tls = new;
// Connect as usual with `tokio-postgres`, providing our `MakeRustlsConnect` as the `tls` arg
let mut pg_config = new;
pg_config
.host
.port
.dbname
.user
.ssl_mode;
let = pg_config.connect.await.expect;
NOTE: please use proper error handling in production code, this is an excerpt from tests that are expected to panic in a failure
License
tokio-postgres-rustls-improved is distributed under the MIT license