postgres_rustls

Rustls-based library for postgres.
git clone https://git.philomathiclife.com/repos/postgres_rustls
Log | Files | Refs | README

commit b891583cd7c3a2ef7e8747e782b75ae2e710f808
parent b7c17eb7b6b0312cab3ae3113b8399a55b1f7373
Author: Zack Newman <zack@philomathiclife.com>
Date:   Tue, 17 Mar 2026 10:43:11 -0600

update deps and lints

Diffstat:
MCargo.toml | 128++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
Msrc/lib.rs | 143++++++++++++++++++++++++++++++++++++++++---------------------------------------
2 files changed, 147 insertions(+), 124 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml @@ -9,60 +9,62 @@ license = "MIT OR Apache-2.0" name = "postgres_rustls" readme = "README.md" repository = "https://git.philomathiclife.com/repos/postgres_rustls/" -rust-version = "1.86.0" -version = "0.1.4" +rust-version = "1.93.1" +version = "0.1.5" [lints.rust] -ambiguous_negative_literals = { level = "deny", priority = -1 } -closure_returning_async_block = { level = "deny", priority = -1 } -deprecated_safe = { level = "deny", priority = -1 } -deref_into_dyn_supertrait = { level = "deny", priority = -1 } -ffi_unwind_calls = { level = "deny", priority = -1 } -future_incompatible = { level = "deny", priority = -1 } -#fuzzy_provenance_casts = { level = "deny", priority = -1 } -impl_trait_redundant_captures = { level = "deny", priority = -1 } -keyword_idents = { level = "deny", priority = -1 } -let_underscore = { level = "deny", priority = -1 } -#linker_messages = { level = "deny", priority = -1 } -#lossy_provenance_casts = { level = "deny", priority = -1 } -macro_use_extern_crate = { level = "deny", priority = -1 } -meta_variable_misuse = { level = "deny", priority = -1 } -missing_copy_implementations = { level = "deny", priority = -1 } -missing_debug_implementations = { level = "deny", priority = -1 } -missing_docs = { level = "deny", priority = -1 } -#multiple_supertrait_upcastable = { level = "deny", priority = -1 } -#must_not_suspend = { level = "deny", priority = -1 } -non_ascii_idents = { level = "deny", priority = -1 } -#non_exhaustive_omitted_patterns = { level = "deny", priority = -1 } -nonstandard_style = { level = "deny", priority = -1 } -redundant_imports = { level = "deny", priority = -1 } -redundant_lifetimes = { level = "deny", priority = -1 } -refining_impl_trait = { level = "deny", priority = -1 } -rust_2018_compatibility = { level = "deny", priority = -1 } -rust_2018_idioms = { level = "deny", priority = -1 } -rust_2021_compatibility = { level = "deny", priority = -1 } -rust_2024_compatibility = { level = "deny", priority = -1 } -single_use_lifetimes = { level = "deny", priority = -1 } -#supertrait_item_shadowing_definition = { level = "deny", priority = -1 } -trivial_casts = { level = "deny", priority = -1 } -trivial_numeric_casts = { level = "deny", priority = -1 } -unit_bindings = { level = "deny", priority = -1 } -unnameable_types = { level = "deny", priority = -1 } -#unqualified_local_imports = { level = "deny", priority = -1 } -unreachable_pub = { level = "deny", priority = -1 } -unsafe_code = { level = "deny", priority = -1 } -unstable_features = { level = "deny", priority = -1 } +deprecated-safe = { level = "deny", priority = -1 } +future-incompatible = { level = "deny", priority = -1 } +keyword-idents = { level = "deny", priority = -1 } +let-underscore = { level = "deny", priority = -1 } +nonstandard-style = { level = "deny", priority = -1 } +refining-impl-trait = { level = "deny", priority = -1 } +rust-2018-compatibility = { level = "deny", priority = -1 } +rust-2018-idioms = { level = "deny", priority = -1 } +rust-2021-compatibility = { level = "deny", priority = -1 } +rust-2024-compatibility = { level = "deny", priority = -1 } +unknown-or-malformed-diagnostic-attributes = { level = "deny", priority = -1 } unused = { level = "deny", priority = -1 } -unused_crate_dependencies = { level = "deny", priority = -1 } -unused_import_braces = { level = "deny", priority = -1 } -unused_lifetimes = { level = "deny", priority = -1 } -unused_qualifications = { level = "deny", priority = -1 } -unused_results = { level = "deny", priority = -1 } -variant_size_differences = { level = "deny", priority = -1 } warnings = { level = "deny", priority = -1 } +ambiguous-negative-literals = { level = "deny", priority = -1 } +closure-returning-async-block = { level = "deny", priority = -1 } +deprecated-in-future = { level = "deny", priority = -1 } +deref-into-dyn-supertrait = { level = "deny", priority = -1 } +ffi-unwind-calls = { level = "deny", priority = -1 } +#fuzzy-provenance-casts = { level = "deny", priority = -1 } +impl-trait-redundant-captures = { level = "deny", priority = -1 } +linker-messages = { level = "deny", priority = -1 } +#lossy-provenance-casts = { level = "deny", priority = -1 } +macro-use-extern-crate = { level = "deny", priority = -1 } +meta-variable-misuse = { level = "deny", priority = -1 } +missing-copy-implementations = { level = "deny", priority = -1 } +missing-debug-implementations = { level = "deny", priority = -1 } +missing-docs = { level = "deny", priority = -1 } +#multiple-supertrait-upcastable = { level = "deny", priority = -1 } +#must-not-suspend = { level = "deny", priority = -1 } +non-ascii-idents = { level = "deny", priority = -1 } +#non-exhaustive-omitted-patterns = { level = "deny", priority = -1 } +redundant-imports = { level = "deny", priority = -1 } +redundant-lifetimes = { level = "deny", priority = -1 } +#resolving-to-items-shadowing-supertrait-items = { level = "deny", priority = -1 } +#shadowing-supertrait-items = { level = "deny", priority = -1 } +single-use-lifetimes = { level = "deny", priority = -1 } +trivial-casts = { level = "deny", priority = -1 } +trivial-numeric-casts = { level = "deny", priority = -1 } +unit-bindings = { level = "deny", priority = -1 } +unnameable-types = { level = "deny", priority = -1 } +#unqualified-local-imports = { level = "deny", priority = -1 } +unreachable-pub = { level = "deny", priority = -1 } +unsafe-code = { level = "deny", priority = -1 } +unstable-features = { level = "deny", priority = -1 } +unused-crate-dependencies = { level = "deny", priority = -1 } +unused-import-braces = { level = "deny", priority = -1 } +unused-lifetimes = { level = "deny", priority = -1 } +unused-qualifications = { level = "deny", priority = -1 } +unused-results = { level = "deny", priority = -1 } +variant-size-differences = { level = "deny", priority = -1 } [lints.clippy] -all = { level = "deny", priority = -1 } cargo = { level = "deny", priority = -1 } complexity = { level = "deny", priority = -1 } correctness = { level = "deny", priority = -1 } @@ -76,23 +78,41 @@ suspicious = { level = "deny", priority = -1 } arbitrary_source_item_ordering = "allow" blanket_clippy_restriction_lints = "allow" implicit_return = "allow" +min_ident_chars = "allow" missing_trait_methods = "allow" +question_mark_used = "allow" +ref_patterns = "allow" return_and_then = "allow" single_call_fn = "allow" +[lints.rustdoc] +all = { level = "deny", priority = -1 } + [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] +default-target = "x86_64-unknown-linux-gnu" +targets = [ + "aarch64-apple-darwin", + "aarch64-pc-windows-msvc", + "aarch64-unknown-linux-gnu", + "i686-pc-windows-msvc", + "i686-unknown-linux-gnu", + "x86_64-pc-windows-gnu", + "x86_64-pc-windows-msvc", + "x86_64-unknown-freebsd", + "x86_64-unknown-linux-musl", + "x86_64-unknown-netbsd" +] [dependencies] sha2 = { version = "0.10.9", default-features = false } -tokio = { version = "1.47.1", default-features = false } -tokio-postgres = { version = "0.7.13", default-features = false } -tokio-rustls = { version = "0.26.2", default-features = false } +tokio = { version = "1.50.0", default-features = false } +tokio-postgres = { version = "0.7.16", default-features = false } +tokio-rustls = { version = "0.26.4", default-features = false } [dev-dependencies] -tokio = { version = "1.47.1", default-features = false, features = ["rt"] } -tokio-rustls = { version = "0.26.2", default-features = false, features = ["ring"] } +tokio = { version = "1.50.0", default-features = false, features = ["rt"] } +tokio-rustls = { version = "0.26.4", default-features = false, features = ["ring"] } ### FEATURES ################################################################# diff --git a/src/lib.rs b/src/lib.rs @@ -10,6 +10,10 @@ clippy::multiple_crate_versions, reason = "dependencies haven't updated to newest crates" )] +#![expect( + clippy::doc_paragraphs_missing_punctuation, + reason = "false positive for crate documentation having image links" +)] use core::{ pin::Pin, task::{Context, Poll}, @@ -475,7 +479,6 @@ impl<S: AsyncRead + AsyncWrite + Unpin> PgTlsConnect<S> for TlsConnector<'static missing_debug_implementations, reason = "TlsConnector does not implement Debug, so we don't" )] -#[cfg_attr(docsrs, doc(cfg(feature = "runtime")))] #[cfg(feature = "runtime")] #[derive(Clone)] pub struct MakeTlsConnector(tokio_rustls::TlsConnector); @@ -543,7 +546,7 @@ mod tests { version::TLS13, }; #[test] - fn test_parse_ed25519() { + fn parse_ed25519() { /// Certificate that uses Ed25519. const CERT: &[u8] = [ 48, 130, 1, 125, 48, 130, 1, 47, 160, 3, 2, 1, 2, 2, 1, 29, 48, 5, 6, 3, 43, 101, 112, @@ -566,13 +569,13 @@ mod tests { 251, 173, 97, 106, 15, 52, 71, 209, 69, 109, 216, 140, 235, 37, 23, 185, 173, 215, 0, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha256(ref hash) => *hash == Sha256::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha256(ref sha_hash) => *sha_hash == Sha256::digest(CERT), + Hash::Sha384(_) | Hash::Sha512(_) | Hash::Sha224(_) => false, + })); } #[test] - fn test_parse_ecdsa_sha256() { + fn parse_ecdsa_sha256() { /// Certificate that uses ECDSA with SHA-256. const CERT: &[u8] = [ 48, 130, 1, 189, 48, 130, 1, 99, 160, 3, 2, 1, 2, 2, 1, 27, 48, 10, 6, 8, 42, 134, 72, @@ -599,13 +602,13 @@ mod tests { 56, 11, 178, 88, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha256(ref hash) => *hash == Sha256::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha256(ref sha_hash) => *sha_hash == Sha256::digest(CERT), + Hash::Sha384(_) | Hash::Sha512(_) | Hash::Sha224(_) => false, + })); } #[test] - fn test_parse_ecdsa_sha384() { + fn parse_ecdsa_sha384() { /// Certificate that uses ECDSA with SHA-384. const CERT: &[u8] = [ 48, 130, 1, 218, 48, 130, 1, 128, 160, 3, 2, 1, 2, 2, 1, 25, 48, 10, 6, 8, 42, 134, 72, @@ -633,13 +636,13 @@ mod tests { 23, 77, 182, 0, 195, 80, 181, 65, 76, 243, 4, 145, 200, 255, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha384(ref hash) => *hash == Sha384::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha384(ref sha_hash) => *sha_hash == Sha384::digest(CERT), + Hash::Sha256(_) | Hash::Sha512(_) | Hash::Sha224(_) => false, + })); } #[test] - fn test_parse_ecdsa_sha512() { + fn parse_ecdsa_sha512() { /// Certificate that uses ECDSA with SHA-512. const CERT: &[u8] = [ 48, 130, 2, 1, 48, 130, 1, 166, 160, 3, 2, 1, 2, 2, 1, 24, 48, 10, 6, 8, 42, 134, 72, @@ -669,13 +672,13 @@ mod tests { 232, 38, 101, 11, 215, 20, 143, 22, 199, 38, 237, 179, 108, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha512(ref hash) => *hash == Sha512::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha512(ref sha_hash) => *sha_hash == Sha512::digest(CERT), + Hash::Sha256(_) | Hash::Sha384(_) | Hash::Sha224(_) => false, + })); } #[test] - fn test_parse_ecdsa_sha224() { + fn parse_ecdsa_sha224() { /// Certificate that uses ECDSA with SHA-224. const CERT: &[u8] = [ 48, 130, 1, 178, 48, 130, 1, 88, 160, 3, 2, 1, 2, 2, 1, 28, 48, 10, 6, 8, 42, 134, 72, @@ -701,13 +704,13 @@ mod tests { 165, 212, 65, 202, 124, 15, 53, 150, 93, 183, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha224(ref hash) => *hash == Sha224::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha224(ref sha_hash) => *sha_hash == Sha224::digest(CERT), + Hash::Sha256(_) | Hash::Sha384(_) | Hash::Sha512(_) => false, + })); } #[test] - fn test_parse_rsa_sha256() { + fn parse_rsa_sha256() { /// Certificate that uses RSA with SHA-256. const CERT: &[u8] = [ 48, 130, 3, 73, 48, 130, 2, 49, 160, 3, 2, 1, 2, 2, 1, 31, 48, 13, 6, 9, 42, 134, 72, @@ -755,13 +758,13 @@ mod tests { 50, 219, 97, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha256(ref hash) => *hash == Sha256::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha256(ref sha_hash) => *sha_hash == Sha256::digest(CERT), + Hash::Sha384(_) | Hash::Sha512(_) | Hash::Sha224(_) => false, + })); } #[test] - fn test_parse_rsa_sha384() { + fn parse_rsa_sha384() { /// Certificate that uses RSA with SHA-384. const CERT: &[u8] = [ 48, 130, 3, 73, 48, 130, 2, 49, 160, 3, 2, 1, 2, 2, 1, 32, 48, 13, 6, 9, 42, 134, 72, @@ -808,13 +811,13 @@ mod tests { 4, 170, 108, 94, 110, 27, 45, 11, 22, 61, 130, 63, 214, 168, 72, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha384(ref hash) => *hash == Sha384::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha384(ref sha_hash) => *sha_hash == Sha384::digest(CERT), + Hash::Sha256(_) | Hash::Sha512(_) | Hash::Sha224(_) => false, + })); } #[test] - fn test_parse_rsa_sha512() { + fn parse_rsa_sha512() { /// Certificate that uses RSA with SHA-512. const CERT: &[u8] = [ 48, 130, 3, 73, 48, 130, 2, 49, 160, 3, 2, 1, 2, 2, 1, 33, 48, 13, 6, 9, 42, 134, 72, @@ -861,13 +864,13 @@ mod tests { 14, 47, 191, 207, 137, 22, 255, 21, 71, 46, 42, 176, 31, 206, 146, 248, 105, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha512(ref hash) => *hash == Sha512::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha512(ref sha_hash) => *sha_hash == Sha512::digest(CERT), + Hash::Sha256(_) | Hash::Sha384(_) | Hash::Sha224(_) => false, + })); } #[test] - fn test_parse_rsa_sha224() { + fn parse_rsa_sha224() { /// Certificate that uses RSA with SHA-224. const CERT: &[u8] = [ 48, 130, 3, 73, 48, 130, 2, 49, 160, 3, 2, 1, 2, 2, 1, 30, 48, 13, 6, 9, 42, 134, 72, @@ -914,13 +917,13 @@ mod tests { 211, 82, 106, 57, 61, 185, 178, 1, 191, 14, 196, 52, 5, 38, 27, 232, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha224(ref hash) => *hash == Sha224::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha224(ref sha_hash) => *sha_hash == Sha224::digest(CERT), + Hash::Sha256(_) | Hash::Sha384(_) | Hash::Sha512(_) => false, + })); } #[test] - fn test_parse_rsa_sha1() { + fn parse_rsa_sha1() { /// Certificate that uses RSA with SHA-1. const CERT: &[u8] = [ 48, 130, 3, 73, 48, 130, 2, 49, 160, 3, 2, 1, 2, 2, 1, 34, 48, 13, 6, 9, 42, 134, 72, @@ -967,13 +970,13 @@ mod tests { 143, 163, 7, 252, 246, 45, 127, 87, 224, 125, 175, 245, 115, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha256(ref hash) => *hash == Sha256::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha256(ref sha_hash) => *sha_hash == Sha256::digest(CERT), + Hash::Sha384(_) | Hash::Sha512(_) | Hash::Sha224(_) => false, + })); } #[test] - fn test_parse_dsa_sha256() { + fn parse_dsa_sha256() { /// Certificate that uses DSA with SHA-256. const CERT: &[u8] = [ 48, 130, 4, 162, 48, 130, 4, 79, 160, 3, 2, 1, 2, 2, 1, 37, 48, 11, 6, 9, 96, 134, 72, @@ -1039,13 +1042,13 @@ mod tests { 148, 80, 118, 28, 75, 176, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha256(ref hash) => *hash == Sha256::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha256(ref sha_hash) => *sha_hash == Sha256::digest(CERT), + Hash::Sha384(_) | Hash::Sha512(_) | Hash::Sha224(_) => false, + })); } #[test] - fn test_parse_dsa_sha224() { + fn parse_dsa_sha224() { /// Certificate that uses DSA with SHA-224. const CERT: &[u8] = [ 48, 130, 4, 163, 48, 130, 4, 79, 160, 3, 2, 1, 2, 2, 1, 36, 48, 11, 6, 9, 96, 134, 72, @@ -1111,13 +1114,13 @@ mod tests { 100, 231, 84, 218, 88, 80, 255, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha224(ref hash) => *hash == Sha224::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha224(ref sha_hash) => *sha_hash == Sha224::digest(CERT), + Hash::Sha256(_) | Hash::Sha384(_) | Hash::Sha512(_) => false, + })); } #[test] - fn test_parse_dsa_sha1() { + fn parse_dsa_sha1() { /// Certificate that uses DSA with SHA-1. const CERT: &[u8] = [ 48, 130, 4, 157, 48, 130, 4, 77, 160, 3, 2, 1, 2, 2, 1, 35, 48, 9, 6, 7, 42, 134, 72, @@ -1183,10 +1186,10 @@ mod tests { 203, 163, 99, ] .as_slice(); - assert!(Hash::from_der_cert(CERT).map_or(false, |hash| match hash { - Hash::Sha256(ref hash) => *hash == Sha256::digest(CERT), - _ => false, - }),); + assert!(Hash::from_der_cert(CERT).is_some_and(|hash| match hash { + Hash::Sha256(ref sha_hash) => *sha_hash == Sha256::digest(CERT), + Hash::Sha384(_) | Hash::Sha512(_) | Hash::Sha224(_) => false, + })); } #[cfg(feature = "runtime")] #[derive(Debug)] @@ -1229,9 +1232,9 @@ mod tests { } } #[cfg(feature = "runtime")] - #[ignore] + #[ignore = "requires proper setup and I/O"] #[test] - fn test_mutual_tls() -> Result<(), E> { + fn mutual_tls() -> Result<(), E> { let root_cert_file = fs::read("test_data/ca.crt.pem")?; let mut cert_iter = CertificateDer::pem_slice_iter(root_cert_file.as_slice()); let key_file = fs::read("test_data/client.key.pem")?; @@ -1291,9 +1294,9 @@ mod tests { .block_on(async move { connection.await.map_err(E::Postgres).map(|_| ()) }) } #[cfg(feature = "runtime")] - #[ignore] + #[ignore = "requires proper setup and I/O"] #[test] - fn test_password_and_channel_binding() -> Result<(), E> { + fn password_and_channel_binding() -> Result<(), E> { let root_cert_file = fs::read("test_data/ca.crt.pem")?; let mut cert_iter = CertificateDer::pem_slice_iter(root_cert_file.as_slice()); let mut conf = ClientConfig::builder_with_protocol_versions([&TLS13].as_slice())