From 244b118a78622073b07f28df4546328bf6008871 Mon Sep 17 00:00:00 2001 From: Elichai Turkel Date: Thu, 15 May 2025 18:47:47 +0300 Subject: [PATCH] Fix NoHostnameTlsVerifier for rustls 0.23.24 and above --- Cargo.lock | 18 ++++++++++-------- sqlx-core/Cargo.toml | 2 +- sqlx-core/src/net/tls/tls_rustls.rs | 6 +++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a5db0c251..ca0133e1c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3030,14 +3030,14 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.9.4", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "rustls" -version = "0.23.21" +version = "0.23.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" +checksum = "730944ca083c1c233a75c09f199e973ca499344a2b7ba9e755c457e86fb4a321" dependencies = [ "aws-lc-rs", "once_cell", @@ -3062,15 +3062,18 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" +checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +dependencies = [ + "zeroize", +] [[package]] name = "rustls-webpki" -version = "0.102.8" +version = "0.103.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" dependencies = [ "aws-lc-rs", "ring", @@ -3653,7 +3656,6 @@ dependencies = [ "sqlx-postgres", "sqlx-sqlite", "syn 2.0.96", - "tempfile", "tokio", "url", ] diff --git a/sqlx-core/Cargo.toml b/sqlx-core/Cargo.toml index f6017a9fee..48e4b8228e 100644 --- a/sqlx-core/Cargo.toml +++ b/sqlx-core/Cargo.toml @@ -39,7 +39,7 @@ tokio = { workspace = true, optional = true } # TLS native-tls = { version = "0.2.10", optional = true } -rustls = { version = "0.23.15", default-features = false, features = ["std", "tls12"], optional = true } +rustls = { version = "0.23.24", default-features = false, features = ["std", "tls12"], optional = true } webpki-roots = { version = "0.26", optional = true } rustls-native-certs = { version = "0.8.0", optional = true } diff --git a/sqlx-core/src/net/tls/tls_rustls.rs b/sqlx-core/src/net/tls/tls_rustls.rs index 1a85cf0ff9..1709c9bdfe 100644 --- a/sqlx-core/src/net/tls/tls_rustls.rs +++ b/sqlx-core/src/net/tls/tls_rustls.rs @@ -306,9 +306,9 @@ impl ServerCertVerifier for NoHostnameTlsVerifier { ocsp_response, now, ) { - Err(TlsError::InvalidCertificate(CertificateError::NotValidForName)) => { - Ok(ServerCertVerified::assertion()) - } + Err(TlsError::InvalidCertificate( + CertificateError::NotValidForName | CertificateError::NotValidForNameContext { .. }, + )) => Ok(ServerCertVerified::assertion()), res => res, } }