diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e066c51..c15fbdb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,6 +60,7 @@ jobs: - run: cargo clippy --all-targets --no-default-features - run: cargo build --all-targets --features native-tls - run: cargo build --all-targets --features rustls-tls + - run: cargo build --all-targets --features rustls-tls-aws - run: cargo clippy --all-targets --all-features test: diff --git a/Cargo.toml b/Cargo.toml index ee30344..9672043 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0" readme = "README.md" edition = "2021" # update `derive/Cargo.toml` and CI if changed -rust-version = "1.67.0" +rust-version = "1.70.0" [lints.rust] rust_2018_idioms = { level = "warn", priority = -1 } @@ -58,8 +58,8 @@ uuid = ["dep:uuid"] time = ["dep:time"] lz4 = ["dep:lz4_flex", "dep:cityhash-rs"] native-tls = ["dep:hyper-tls"] -rustls-tls = ["dep:hyper-rustls", "hyper-rustls?/ring"] -rustls-tls-aws = ["dep:hyper-rustls", "hyper-rustls?/aws-lc-rs"] +rustls-tls = ["dep:hyper-rustls", "dep:rustls", "hyper-rustls?/ring"] +rustls-tls-aws = ["dep:hyper-rustls", "dep:rustls", "hyper-rustls?/aws-lc-rs"] [dependencies] clickhouse-derive = { version = "0.2.0", path = "derive" } @@ -72,6 +72,7 @@ http-body-util = "0.1.2" hyper = "1.4" hyper-util = { version = "0.1.6", features = ["client-legacy", "http1"] } hyper-tls = { version = "0.6.0", optional = true } +rustls = { version = "0.23", default-features = false, optional = true } hyper-rustls = { version = "0.27.2", default-features = false, features = [ "http1", "http2", diff --git a/derive/Cargo.toml b/derive/Cargo.toml index e0b86ec..d1129c1 100644 --- a/derive/Cargo.toml +++ b/derive/Cargo.toml @@ -7,7 +7,8 @@ repository = "https://github.com/ClickHouse/clickhouse-rs" homepage = "https://clickhouse.com" edition = "2021" license = "MIT OR Apache-2.0" -rust-version = "1.67.0" # update `Cargo.toml` and CI if changed +# update `Cargo.toml` and CI if changed +rust-version = "1.70.0" [lib] proc-macro = true diff --git a/src/lib.rs b/src/lib.rs index 112a14e..584b86c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,6 +48,19 @@ const TCP_KEEPALIVE: Duration = Duration::from_secs(60); // See https://github.com/ClickHouse/ClickHouse/blob/368cb74b4d222dc5472a7f2177f6bb154ebae07a/programs/server/config.xml#L201 const POOL_IDLE_TIMEOUT: Duration = Duration::from_secs(2); +#[cfg(any(feature = "rustls-tls", feature = "rustls-tls-aws"))] +fn prepare_hyper_rustls_client( + connector: HttpConnector, + provider: impl Into>, +) -> hyper_rustls::HttpsConnector { + hyper_rustls::HttpsConnectorBuilder::new() + .with_provider_and_webpki_roots(provider) + .unwrap() + .https_or_http() + .enable_http1() + .wrap_connector(connector) +} + /// A client containing HTTP pool. #[derive(Clone)] pub struct Client { @@ -70,18 +83,26 @@ impl Default for Client { // TODO: make configurable in `Client::builder()`. connector.set_keepalive(Some(TCP_KEEPALIVE)); - #[cfg(any(feature = "native-tls", feature = "rustls-tls"))] + #[cfg(any( + feature = "native-tls", + feature = "rustls-tls", + feature = "rustls-tls-aws" + ))] connector.enforce_http(false); - #[cfg(all(feature = "native-tls", not(feature = "rustls-tls")))] + #[cfg(all( + feature = "native-tls", + not(feature = "rustls-tls"), + not(feature = "rustls-tls-aws") + ))] let connector = hyper_tls::HttpsConnector::new_with_connector(connector); #[cfg(feature = "rustls-tls")] - let connector = hyper_rustls::HttpsConnectorBuilder::new() - .with_webpki_roots() - .https_or_http() - .enable_http1() - .wrap_connector(connector); + let connector = + prepare_hyper_rustls_client(connector, rustls::crypto::ring::default_provider()); + #[cfg(feature = "rustls-tls-aws")] + let connector = + prepare_hyper_rustls_client(connector, rustls::crypto::aws_lc_rs::default_provider()); let client = HyperClient::builder(TokioExecutor::new()) .pool_idle_timeout(POOL_IDLE_TIMEOUT)