25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(postgres): skip cert parsing for non-verifying TLS
t8y23161efe95f93
diff --git a/crates/dbx-core/src/db/postgres.rs b/crates/dbx-core/src/db/postgres.rsindex 1b19e86ded..2fbc8dcae0 100644--- a/crates/dbx-core/src/db/postgres.rs+++ b/crates/dbx-core/src/db/postgres.rs@@ -1289,20 +1289,20 @@ impl ServerCertVerifier for NoPostgresCertVerification {fn verify_tls12_signature(&self,- message: &[u8],+ _message: &[u8],cert: &CertificateDer<'_>,- dss: &rustls::DigitallySignedStruct,+ _dss: &rustls::DigitallySignedStruct,) -> Result<HandshakeSignatureValid, rustls::Error> {- verify_tls12_signature(message, cert, dss, &self.provider.signature_verification_algorithms)+ self.accept_tls_signature_for_unverified_cert(cert)}fn verify_tls13_signature(&self,- message: &[u8],+ _message: &[u8],cert: &CertificateDer<'_>,- dss: &rustls::DigitallySignedStruct,+ _dss: &rustls::DigitallySignedStruct,) -> Result<HandshakeSignatureValid, rustls::Error> {- verify_tls13_signature(message, cert, dss, &self.provider.signature_verification_algorithms)+ self.accept_tls_signature_for_unverified_cert(cert)}fn supported_verify_schemes(&self) -> Vec<rustls::SignatureScheme> {@@ -1310,6 +1310,19 @@ impl ServerCertVerifier for NoPostgresCertVerification {}}+impl NoPostgresCertVerification {+ fn accept_tls_signature_for_unverified_cert(+ &self,+ _cert: &CertificateDer<'_>,+ ) -> Result<HandshakeSignatureValid, rustls::Error> {+ // PostgreSQL sslmode=prefer/require does not authenticate the server certificate.+ // Avoid rustls' default signature helpers here because they parse the certificate+ // before chain verification and reject legacy server certificates that libpq/JDBC+ // still accept in these non-verifying modes.+ Ok(HandshakeSignatureValid::assertion())+ }+}+#[derive(Debug)]struct PostgresCaOnlyCertVerification {provider: Arc<CryptoProvider>,@@ -3389,6 +3402,14 @@ mod tests {assert!(error.contains("sslkey"));}+ #[test]+ fn postgres_accept_all_tls_signature_does_not_parse_unverified_cert() {+ let verifier = NoPostgresCertVerification { provider: Arc::new(rustls::crypto::aws_lc_rs::default_provider()) };+ let malformed_cert = CertificateDer::from(vec![0x30, 0x03, 0x02, 0x01, 0x00]);++ assert!(verifier.accept_tls_signature_for_unverified_cert(&malformed_cert).is_ok());+ }+#[test]fn inject_postgres_keepalive_params_preserves_url_fragment() {let url = "postgres://localhost/app?sslmode=require#read-only";