diff options
author | Ava Hahn <a.hahn@f5.com> | 2024-09-23 11:44:46 -0700 |
---|---|---|
committer | Ava Hahn <110854134+avahahn@users.noreply.github.com> | 2024-09-24 10:53:32 -0700 |
commit | 1c75aab380a24c3b8ebbac9059e9dc288812a83b (patch) | |
tree | 68fa343070e31a27d1d3da90a133b77ae1c11c52 | |
parent | a9d687e77059e801e956e7b7bb59637aa4708483 (diff) | |
download | unit-1c75aab380a24c3b8ebbac9059e9dc288812a83b.tar.gz unit-1c75aab380a24c3b8ebbac9059e9dc288812a83b.tar.bz2 |
tools/unitctl: use hyper-rustls instead of hyper-tls
Signed-off-by: Ava Hahn <a.hahn@f5.com>
-rw-r--r-- | tools/unitctl/Cargo.lock | 69 | ||||
-rw-r--r-- | tools/unitctl/unit-client-rs/Cargo.toml | 2 | ||||
-rw-r--r-- | tools/unitctl/unit-client-rs/src/lib.rs | 1 | ||||
-rw-r--r-- | tools/unitctl/unit-client-rs/src/unit_client.rs | 11 |
4 files changed, 77 insertions, 6 deletions
diff --git a/tools/unitctl/Cargo.lock b/tools/unitctl/Cargo.lock index 58f07b8b..b8af9fc6 100644 --- a/tools/unitctl/Cargo.lock +++ b/tools/unitctl/Cargo.lock @@ -837,6 +837,24 @@ dependencies = [ ] [[package]] +name = "hyper-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "399c78f9338483cb7e630c8474b07268983c6bd5acee012e4211f9f7bb21b070" +dependencies = [ + "futures-util", + "http 0.2.8", + "hyper 0.14.27", + "log", + "rustls 0.22.4", + "rustls-native-certs", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "webpki-roots", +] + +[[package]] name = "hyper-tls" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1502,6 +1520,20 @@ dependencies = [ [[package]] name = "rustls" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls" version = "0.23.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afabcee0551bd1aa3e18e5adbf2c0544722014b899adb31bd186ec638d3da97e" @@ -1516,6 +1548,19 @@ dependencies = [ ] [[package]] +name = "rustls-native-certs" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] name = "rustls-pemfile" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1918,6 +1963,17 @@ dependencies = [ ] [[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.4", + "rustls-pki-types", + "tokio", +] + +[[package]] name = "tokio-util" version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2028,12 +2084,12 @@ dependencies = [ "futures", "hex", "hyper 0.14.27", - "hyper-tls", + "hyper-rustls", "hyperlocal", "pbr", "rand", "regex", - "rustls", + "rustls 0.23.5", "serde", "serde_json", "sysinfo", @@ -2203,6 +2259,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] +name = "webpki-roots" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +dependencies = [ + "rustls-pki-types", +] + +[[package]] name = "which" version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/tools/unitctl/unit-client-rs/Cargo.toml b/tools/unitctl/unit-client-rs/Cargo.toml index 6d873417..6518f620 100644 --- a/tools/unitctl/unit-client-rs/Cargo.toml +++ b/tools/unitctl/unit-client-rs/Cargo.toml @@ -15,7 +15,7 @@ default = ["serde_json/preserve_order"] [dependencies] custom_error = "1.9" hyper = { version = "0.14", features = ["stream"] } -hyper-tls = "0.5" +hyper-rustls = { version = "0.25.0", features = ["rustls-native-certs", "webpki-roots"] } hyperlocal = "0.8" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/tools/unitctl/unit-client-rs/src/lib.rs b/tools/unitctl/unit-client-rs/src/lib.rs index a0933f42..59dd2681 100644 --- a/tools/unitctl/unit-client-rs/src/lib.rs +++ b/tools/unitctl/unit-client-rs/src/lib.rs @@ -1,7 +1,6 @@ extern crate custom_error; extern crate futures; extern crate hyper; -extern crate hyper_tls; extern crate hyperlocal; extern crate serde; extern crate serde_json; diff --git a/tools/unitctl/unit-client-rs/src/unit_client.rs b/tools/unitctl/unit-client-rs/src/unit_client.rs index 3d09e67a..bc6cc4f7 100644 --- a/tools/unitctl/unit-client-rs/src/unit_client.rs +++ b/tools/unitctl/unit-client-rs/src/unit_client.rs @@ -9,7 +9,7 @@ use hyper::body::{Buf, HttpBody}; use hyper::client::{HttpConnector, ResponseFuture}; use hyper::Error as HyperError; use hyper::{http, Body, Client, Request}; -use hyper_tls::HttpsConnector; +use hyper_rustls::{HttpsConnectorBuilder, HttpsConnector}; use hyperlocal::{UnixClientExt, UnixConnector}; use serde::{Deserialize, Serialize}; @@ -185,7 +185,14 @@ impl UnitClient { } pub fn new_http(control_socket: ControlSocket) -> Self { - let remote_client = Client::builder().build(HttpsConnector::new()); + let remote_client = Client::builder() + .build(HttpsConnectorBuilder::default() + .with_native_roots() + .unwrap_or_else(|_| HttpsConnectorBuilder::default() + .with_webpki_roots()) + .https_or_http() + .enable_http1() + .wrap_connector(HttpConnector::new())); Self { control_socket, client: Box::from(RemoteClient::Tcp { client: remote_client }), |