From 2876dfc1ea6bfd94f3d08b8414729b205873ad43 Mon Sep 17 00:00:00 2001 From: Nugraha Date: Thu, 28 Dec 2023 13:03:33 +0700 Subject: [PATCH] feat(volo): add feature `vendored` for `native-tls` Add feature `vendored` that enables `tokio-native-tls/vendored`, and use it in CI to avoid installing additional packages. --- .github/workflows/ci.yaml | 4 ++++ Cargo.lock | 19 +++++++++++++++++-- volo/Cargo.toml | 1 + volo/src/net/dial.rs | 4 ++-- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 20792f4d..3e4ee4e4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,6 +34,7 @@ jobs: - name: Run tests run: | cargo check --features multiplex + cargo check --features rustls,native-tls,vendored cargo test test-linux-aarch64: @@ -48,6 +49,7 @@ jobs: - name: Run tests run: | cargo check --features multiplex + cargo check --features rustls,native-tls,vendored cargo test test-macos: @@ -62,6 +64,7 @@ jobs: - name: Run tests run: | cargo check --features multiplex + cargo check --features rustls,native-tls,vendored cargo test test-windows: @@ -76,6 +79,7 @@ jobs: - name: Run tests run: | cargo check --features multiplex + cargo check --features rustls,native-tls,vendored cargo test lint: diff --git a/Cargo.lock b/Cargo.lock index 50b37e22..7325ab3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1449,6 +1449,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.2.1+3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fe476c29791a5ca0d1273c697e96085bbabbbea2ef7afd5617e78a4b40332d3" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.97" @@ -1457,6 +1466,7 @@ checksum = "c3eaad34cdd97d81de97964fc7f29e2d104f483840d906ef56daa1912338460b" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -1932,7 +1942,9 @@ dependencies = [ "serde_urlencoded", "system-configuration", "tokio", + "tokio-native-tls", "tokio-rustls 0.24.1", + "tokio-util", "tower-service", "url", "wasm-bindgen", @@ -2037,9 +2049,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7673e0aa20ee4937c6aacfc12bb8341cfbf054cdd21df6bec5fd0629fe9339b" +checksum = "9e9d979b3ce68192e42760c7810125eb6cf2ea10efae545a156063e61f314e2a" [[package]] name = "rustls-webpki" @@ -2778,6 +2790,8 @@ dependencies = [ "dashmap", "faststr", "futures", + "hyper 1.1.0", + "hyper-util", "lazy_static", "libc", "metainfo", @@ -2787,6 +2801,7 @@ dependencies = [ "once_cell", "pin-project", "rand", + "reqwest", "rustls 0.22.1", "socket2", "thiserror", diff --git a/volo/Cargo.toml b/volo/Cargo.toml index 3718c2b7..fd491770 100644 --- a/volo/Cargo.toml +++ b/volo/Cargo.toml @@ -58,5 +58,6 @@ tokio-native-tls = { workspace = true, optional = true } [features] default = [] +vendored = ["tokio-native-tls/vendored"] rustls = ["tokio-rustls", "librustls"] native-tls = ["tokio-native-tls"] \ No newline at end of file diff --git a/volo/src/net/dial.rs b/volo/src/net/dial.rs index efef8a9e..6b6deaa3 100644 --- a/volo/src/net/dial.rs +++ b/volo/src/net/dial.rs @@ -204,8 +204,8 @@ cfg_rustls_or_native_tls! { match &self.tls_config.connector { #[cfg(feature = "rustls")] TlsConnector::Rustls(connector) => { - let server_name = librustls::ServerName::try_from(&self.tls_config.server_name[..]) - .map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?; + let server_name = librustls::pki_types::ServerName::try_from(&self.tls_config.server_name[..]) + .map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?.to_owned(); connector .connect(server_name, tcp) .await