Skip to content

Commit

Permalink
Merge pull request #21 from second-state/chore/update_dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
juntao authored Apr 29, 2024
2 parents 2dc4198 + 4eca325 commit 8b81bca
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 12 deletions.
3 changes: 3 additions & 0 deletions client-https/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build]
target = "wasm32-wasi"
rustflags = ["--cfg", "wasmedge", "--cfg", "tokio_unstable"]
24 changes: 19 additions & 5 deletions client-https/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
18 changes: 15 additions & 3 deletions client-https/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
3 changes: 3 additions & 0 deletions client/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build]
target = "wasm32-wasi"
rustflags = ["--cfg", "wasmedge", "--cfg", "tokio_unstable"]
9 changes: 7 additions & 2 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions server/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build]
target = "wasm32-wasi"
rustflags = ["--cfg", "wasmedge", "--cfg", "tokio_unstable"]
9 changes: 7 additions & 2 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}

0 comments on commit 8b81bca

Please sign in to comment.