diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 81b19bd166..4abc6ef496 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -41,12 +41,19 @@ jobs: run: cargo clippy --verbose --all-targets --all-features - name: Cargo check with cpp_rust_unstable cfg run: RUSTFLAGS="--cfg cpp_rust_unstable" cargo clippy --verbose --all-targets --all-features + +# Features checks. + # No features. - name: Cargo check without features run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "" - - name: Cargo check with all serialization features - run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "full-serialization" + + # All features. - name: Cargo check with all features run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --all-features + + # Various (de)serialization features. + - name: Cargo check with all serialization features + run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "full-serialization" - name: Cargo check with secrecy-08 feature run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "secrecy-08" - name: Cargo check with chrono-04 feature @@ -59,6 +66,14 @@ jobs: run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "num-bigint-04" - name: Cargo check with bigdecimal-04 feature run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "bigdecimal-04" + + # TLS-related feature sets. + - name: Cargo check with openssl-x feature + run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "openssl-010" + - name: Cargo check with rustls-x feature + run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "rustls-023" + # (openssl-x, rustls-x) is checked in tls.yml. + - name: Build scylla-cql run: cargo build --verbose --all-targets --manifest-path "scylla-cql/Cargo.toml" --features "full-serialization" - name: Build diff --git a/.github/workflows/serverless.yaml b/.github/workflows/serverless.yaml index 9da2f05f6c..83e42f44a7 100644 --- a/.github/workflows/serverless.yaml +++ b/.github/workflows/serverless.yaml @@ -11,6 +11,7 @@ on: env: CARGO_TERM_COLOR: always RUST_BACKTRACE: full + RUSTFLAGS: -Dwarnings jobs: build: @@ -31,8 +32,18 @@ jobs: run: rustup update - name: Check run: cargo check --verbose - - name: Run cloud example - run: cargo run --example cloud -- $HOME/.ccm/serverless/config_data.yaml + # Cloud-related feature sets. + - name: Cargo check with unstable-cloud and openssl-x features + run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "unstable-cloud" --features "openssl-010" + - name: Cargo check with unstable-cloud and rustls-x features + run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "unstable-cloud" --features "rustls-023" + - name: Cargo check with unstable-cloud, openssl-x and rustls-x features + run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "unstable-cloud" --features "openssl-010" --features "rustls-023" + + - name: Run cloud-openssl example + run: cargo run --example cloud-openssl -- $HOME/.ccm/serverless/config_data.yaml + - name: Run cloud-rustls example + run: cargo run --example cloud-rustls -- $HOME/.ccm/serverless/config_data.yaml - name: Run cloud tests run: CLOUD_CONFIG_PATH=$HOME/.ccm/serverless/config_data.yaml RUSTFLAGS="--cfg scylla_cloud_tests" RUST_LOG=trace cargo test --verbose diff --git a/.github/workflows/tls.yml b/.github/workflows/tls.yml index e588a1ed2d..4d124ae821 100644 --- a/.github/workflows/tls.yml +++ b/.github/workflows/tls.yml @@ -26,14 +26,16 @@ jobs: run: rustup update - name: Check - run: cargo check --verbose --features "ssl" + run: cargo check --verbose --features "openssl-010" --features "rustls-023" working-directory: ${{env.working-directory}} - name: Start the cluster run: docker compose -f test/tls/docker-compose-tls.yml up -d - - name: Run tests - run: SCYLLA_URI=172.44.0.2 RUST_LOG=trace cargo run --example tls + - name: Run openssl example + run: SCYLLA_URI=172.44.0.2 RUST_LOG=trace cargo run --example tls-openssl + - name: Run rustls example + run: SCYLLA_URI=172.44.0.2 RUST_LOG=trace cargo run --example tls-rustls - name: Stop the cluster if: ${{ always() }} diff --git a/Cargo.lock.msrv b/Cargo.lock.msrv index a6ded1aec3..e22cc2f1a1 100644 --- a/Cargo.lock.msrv +++ b/Cargo.lock.msrv @@ -117,6 +117,31 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "aws-lc-rs" +version = "1.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd755adf9707cf671e31d944a189be3deaaeee11c8bc1d669bb8022ac90fbd0" +dependencies = [ + "aws-lc-sys", + "paste", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f9dd2e03ee80ca2822dd6ea431163d2ef259f2066a4d6ccaca6d9dcb386aa43" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", + "paste", +] + [[package]] name = "backtrace" version = "0.3.71" @@ -151,6 +176,29 @@ dependencies = [ "num-traits", ] +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags 2.5.0", + "cexpr", + "clang-sys", + "itertools 0.10.5", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.90", + "which", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -189,9 +237,23 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.97" +version = "1.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c736e259eea577f443d5c86c304f9f4ae0295c43f3ba05c21f1d66b5f06001af" +dependencies = [ + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cexpr" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] [[package]] name = "cfg-if" @@ -238,6 +300,17 @@ dependencies = [ "half", ] +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "3.2.25" @@ -288,6 +361,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "cmake" +version = "0.1.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" +dependencies = [ + "cc", +] + [[package]] name = "core-foundation-sys" version = "0.8.6" @@ -439,6 +521,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "either" version = "1.11.0" @@ -501,6 +589,7 @@ dependencies = [ "futures", "openssl", "rand", + "rustls", "rustyline", "rustyline-derive", "scylla", @@ -554,6 +643,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" version = "0.3.30" @@ -672,6 +767,12 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + [[package]] name = "half" version = "2.4.1" @@ -725,6 +826,15 @@ version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12cb882ccb290b8646e554b157ab0b71e64e8d5bef775cd66b6531e52d302669" +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "humantime" version = "2.1.0" @@ -825,6 +935,15 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.69" @@ -840,11 +959,27 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" -version = "0.2.154" +version = "0.2.170" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" + +[[package]] +name = "libloading" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +dependencies = [ + "cfg-if", + "windows-targets 0.48.5", +] [[package]] name = "libm" @@ -917,6 +1052,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.2" @@ -959,6 +1100,16 @@ dependencies = [ "memoffset", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "ntest" version = "0.9.3" @@ -1080,9 +1231,9 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "openssl" -version = "0.10.64" +version = "0.10.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +checksum = "5e14130c6a98cd258fdcb0fb6d744152343ff729cbfcb28c656a9d12b999fbcd" dependencies = [ "bitflags 2.5.0", "cfg-if", @@ -1106,9 +1257,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.102" +version = "0.9.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +checksum = "8bb61ea9811cc39e3c2069f40b8b8e2e70d8569b361f879786cc7ed48b777cdd" dependencies = [ "cc", "libc", @@ -1151,6 +1302,12 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1215,6 +1372,16 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "prettyplease" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +dependencies = [ + "proc-macro2", + "syn 2.0.90", +] + [[package]] name = "proc-macro-crate" version = "3.1.0" @@ -1400,12 +1567,32 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +[[package]] +name = "ring" +version = "0.17.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da5349ae27d3887ca812fb375b45a4fbb36d8d12d2df394968cd86e35683fe73" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.15", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rustc-demangle" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustix" version = "0.38.34" @@ -1419,6 +1606,39 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.23.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" +dependencies = [ + "aws-lc-rs", + "log", + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" + +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustyline" version = "9.1.2" @@ -1501,6 +1721,7 @@ dependencies = [ "rand", "rand_chacha", "rand_pcg", + "rustls", "scylla-cql", "scylla-macros", "scylla-proxy", @@ -1513,6 +1734,7 @@ dependencies = [ "time", "tokio", "tokio-openssl", + "tokio-rustls", "tracing", "tracing-subscriber", "url", @@ -1640,6 +1862,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -1716,6 +1944,12 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "1.0.109" @@ -1911,6 +2145,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" +dependencies = [ + "rustls", + "tokio", +] + [[package]] name = "toml_datetime" version = "0.6.5" @@ -2062,6 +2306,12 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.0" @@ -2196,6 +2446,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/README.md b/README.md index e9f701fa66..9589e6cbe1 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ The driver supports the following: * Batch statements * Configurable load balancing policies * Driver-side metrics -* TLS support - install openssl if you want to use it https://docs.rs/openssl/0.10.32/openssl/#automatic +* TLS support. Supports either [OpenSSL](https://docs.rs/openssl/0.10.70/openssl/#automatic) or [rustls](https://docs.rs/rustls/latest/rustls/) * Configurable retry policies * Authentication support * CQL tracing diff --git a/docs/source/connecting/connecting.md b/docs/source/connecting/connecting.md index 5e27198657..3aca5a5aa5 100644 --- a/docs/source/connecting/connecting.md +++ b/docs/source/connecting/connecting.md @@ -68,20 +68,27 @@ specify the secure connection bundle as follows: use std::path::Path; use std::error::Error; use scylla::client::session_builder::CloudSessionBuilder; +use scylla::cloud::CloudTlsProvider; #[tokio::main] async fn main() -> Result<(), Box> { - let session = CloudSessionBuilder::new(Path::new("config_data.yaml")) - .unwrap() - .build() - .await - .unwrap(); + let session = + CloudSessionBuilder::new(Path::new("config_data.yaml"), CloudTlsProvider::OpenSsl010) + .unwrap() + .build() + .await + .unwrap(); Ok(()) } # } ``` +> ***Note***\ +> `CloudSessionBuilder::new()` accepts two parameters. The first is a path to the configuration file. +> The second parameter is responsible for choosing the underlying TLS provider library. +> For more information about providers supported currently by the driver, see [TLS](tls.md). + Note that the bundle file will be provided after the serverless cluster is created. Here is an example of a configuration file for a serverless cluster: diff --git a/docs/source/connecting/tls.md b/docs/source/connecting/tls.md index 88e472315b..e6df0a0d46 100644 --- a/docs/source/connecting/tls.md +++ b/docs/source/connecting/tls.md @@ -1,21 +1,25 @@ # TLS -Driver uses the [`openssl`](https://github.com/sfackler/rust-openssl) crate for TLS functionality.\ -It was chosen because [`rustls`](https://github.com/ctz/rustls) doesn't support certificates for ip addresses -(see [issue](https://github.com/briansmith/webpki/issues/54)), which is a common use case for Scylla. +Driver uses either the +[`openssl`](https://github.com/sfackler/rust-openssl) crate or the +[`rustls`](https://github.com/rustls/rustls) crate for TLS functionality. + +Both of this features are behind their respective feature flag. ### Enabling feature -`openssl` is not a pure Rust library so you need enable a feature and install the proper package. -To enable the `tls` feature add in `Cargo.toml`: +**_NOTE:_** `openssl` is not a pure Rust library, so you need to **both** enable a feature **and** install the proper package. + +To enable use of TLS using `openssl`, add in `Cargo.toml`: + ```toml -scylla = { version = "0.4", features = ["ssl"] } -openssl = "0.10.32" +scylla = { version = "0.4", features = ["openssl-010"] } +openssl = "0.10.70" ``` Then install the package with `openssl`: -* Debian/Ubuntu: +* Debian/Ubuntu: ```bash apt install libssl-dev pkg-config ``` @@ -23,7 +27,7 @@ Then install the package with `openssl`: ```bash dnf install openssl-devel ``` -