From e8ba04cae9684919539a8321d0f13ecd26a9aa79 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Mon, 22 Apr 2024 22:56:54 +0800 Subject: [PATCH 1/3] Update client Cargo.toml Signed-off-by: csh <458761603@qq.com> --- client/.cargo/config | 3 +++ client/Cargo.toml | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 client/.cargo/config diff --git a/client/.cargo/config b/client/.cargo/config new file mode 100644 index 0000000..c20090b --- /dev/null +++ b/client/.cargo/config @@ -0,0 +1,3 @@ +[build] +target = "wasm32-wasi" +rustflags = ["--cfg", "wasmedge", "--cfg", "tokio_unstable"] diff --git a/client/Cargo.toml b/client/Cargo.toml index 4648009..834cad6 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -3,9 +3,14 @@ name = "wasmedge_hyper_client" version = "0.1.0" edition = "2021" +[patch.crates-io] +tokio = { git = "https://github.com/second-state/wasi_tokio.git", branch = "v1.36.x" } +socket2 = { git = "https://github.com/second-state/socket2.git", branch = "v0.5.x" } +hyper = { git = "https://github.com/second-state/wasi_hyper.git", branch = "v0.14.x" } + [dependencies] -hyper_wasi = { version = "0.15", features = ["full"] } -tokio_wasi = { version = "1", features = [ +hyper = { version = "0.14", features = ["full"] } +tokio = { version = "1", features = [ "rt", "macros", "net", From caaae10b6b5f2a5edebe7728abfd2835a5566600 Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Mon, 22 Apr 2024 23:07:04 +0800 Subject: [PATCH 2/3] Update client-https Cargo.toml Signed-off-by: csh <458761603@qq.com> --- client-https/.cargo/config.toml | 3 +++ client-https/Cargo.toml | 24 +++++++++++++++++++----- client-https/src/main.rs | 18 +++++++++++++++--- 3 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 client-https/.cargo/config.toml diff --git a/client-https/.cargo/config.toml b/client-https/.cargo/config.toml new file mode 100644 index 0000000..c20090b --- /dev/null +++ b/client-https/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "wasm32-wasi" +rustflags = ["--cfg", "wasmedge", "--cfg", "tokio_unstable"] diff --git a/client-https/Cargo.toml b/client-https/Cargo.toml index c9fef62..4f4dc37 100644 --- a/client-https/Cargo.toml +++ b/client-https/Cargo.toml @@ -4,11 +4,25 @@ version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[patch.crates-io] +tokio = { git = "https://github.com/second-state/wasi_tokio.git", branch = "v1.36.x" } +# mio = { git = "https://github.com/second-state/wasi_mio.git", branch = "v0.8.x" } +socket2 = { git = "https://github.com/second-state/socket2.git", branch = "v0.5.x" } +hyper = { git = "https://github.com/second-state/wasi_hyper.git", branch = "v0.14.x" } + [dependencies] -hyper_wasi = { version = "0.15", features = ["full"]} -http-body-util = "0.1.0-rc.2" -tokio_wasi = { version = "1", features = ["rt", "macros", "net", "time", "io-util"]} +hyper = { version = "0.14", features = ["full"]} +hyper-rustls = { version = "0.25", default-features = false, features = [ + "http1", + "tls12", + "logging", + "ring", + "webpki-tokio", +] } + +tokio = { version = "1", features = ["rt", "macros", "net", "time", "io-util"]} pretty_env_logger = "0.4.0" -wasmedge_rustls_api = { version = "0.1", features = [ "tokio_async" ] } -wasmedge_hyper_rustls = "0.1.0" + +rustls = { version = "0.22", default-features = false } +webpki-roots = "0.26.1" diff --git a/client-https/src/main.rs b/client-https/src/main.rs index 4630c90..e596831 100644 --- a/client-https/src/main.rs +++ b/client-https/src/main.rs @@ -11,9 +11,21 @@ async fn main() { } async fn fetch_https_url(url: hyper::Uri) -> Result<()> { - let https = wasmedge_hyper_rustls::connector::new_https_connector( - wasmedge_rustls_api::ClientConfig::default(), - ); + // Prepare the TLS client config + let mut root_store = rustls::RootCertStore::empty(); + root_store.extend(webpki_roots::TLS_SERVER_ROOTS.iter().cloned()); + + let tls = rustls::ClientConfig::builder() + .with_root_certificates(root_store) + .with_no_client_auth(); + + // Prepare the HTTPS connector + let https = hyper_rustls::HttpsConnectorBuilder::new() + .with_tls_config(tls) + .https_or_http() + .enable_http1() + .build(); + let client = Client::builder().build::<_, hyper::Body>(https); let res = client.get(url).await?; From 4eca3256201359ce716df8a7ba69d8eb84caed1a Mon Sep 17 00:00:00 2001 From: csh <458761603@qq.com> Date: Tue, 23 Apr 2024 01:09:52 +0800 Subject: [PATCH 3/3] Update server/Cargo.toml Signed-off-by: csh <458761603@qq.com> --- server/.cargo/config.toml | 3 +++ server/Cargo.toml | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 server/.cargo/config.toml diff --git a/server/.cargo/config.toml b/server/.cargo/config.toml new file mode 100644 index 0000000..c20090b --- /dev/null +++ b/server/.cargo/config.toml @@ -0,0 +1,3 @@ +[build] +target = "wasm32-wasi" +rustflags = ["--cfg", "wasmedge", "--cfg", "tokio_unstable"] diff --git a/server/Cargo.toml b/server/Cargo.toml index 0c78db6..10e789d 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -3,6 +3,11 @@ name = "wasmedge_hyper_server" version = "0.1.0" edition = "2021" +[patch.crates-io] +tokio = { git = "https://github.com/second-state/wasi_tokio.git", branch = "v1.36.x" } +socket2 = { git = "https://github.com/second-state/socket2.git", branch = "v0.5.x" } +hyper = { git = "https://github.com/second-state/wasi_hyper.git", branch = "v0.14.x" } + [dependencies] -hyper_wasi = { version = "0.15", features = ["full"]} -tokio_wasi = { version = "1", features = ["rt", "macros", "net", "time", "io-util"]} +hyper = { version = "0.14", features = ["full"]} +tokio = { version = "1", features = ["rt", "macros", "net", "time", "io-util"]}