From 842df6a9ff550547851870207968add69796f038 Mon Sep 17 00:00:00 2001 From: Fina Wilke Date: Mon, 22 Apr 2024 16:55:33 +0200 Subject: [PATCH 1/2] async-tungstenite: Make TLS features optional The included TLS features are only required for wss connections to the mailbox server which not required by the protocol and only really useful for wasm builds. Closes #216 --- Cargo.lock | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 10 ++-- 2 files changed, 137 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a978b0d..8ad23ee1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -256,6 +256,18 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "async-native-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9343dc5acf07e79ff82d0c37899f079db3534d99f189a1837c8e549c99405bec" +dependencies = [ + "futures-util", + "native-tls", + "thiserror", + "url", +] + [[package]] name = "async-process" version = "1.8.1" @@ -369,6 +381,7 @@ version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cca750b12e02c389c1694d35c16539f88b8bbaa5945934fdc1b41a776688589" dependencies = [ + "async-native-tls", "async-std", "async-tls", "futures-io", @@ -727,7 +740,7 @@ dependencies = [ "bitflags 1.3.2", "core-foundation", "core-graphics-types", - "foreign-types", + "foreign-types 0.5.0", "libc", ] @@ -1139,6 +1152,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared 0.1.1", +] + [[package]] name = "foreign-types" version = "0.5.0" @@ -1146,7 +1168,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" dependencies = [ "foreign-types-macros", - "foreign-types-shared", + "foreign-types-shared 0.3.1", ] [[package]] @@ -1160,6 +1182,12 @@ dependencies = [ "syn 2.0.60", ] +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "foreign-types-shared" version = "0.3.1" @@ -1750,6 +1778,24 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nix" version = "0.28.0" @@ -1867,6 +1913,50 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "foreign-types 0.3.2", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "os_pipe" version = "1.1.5" @@ -2396,6 +2486,15 @@ dependencies = [ "cipher", ] +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -2418,6 +2517,29 @@ dependencies = [ "untrusted", ] +[[package]] +name = "security-framework" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.22" @@ -2881,6 +3003,7 @@ dependencies = [ "http", "httparse", "log", + "native-tls", "rand", "sha1", "thiserror", @@ -2973,6 +3096,12 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74797339c3b98616c009c7c3eb53a0ce41e85c8ec66bd3db96ed132d20cfdee8" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index 727506e1..2bdc1b25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,10 +63,7 @@ tar = { version = "0.4.33", optional = true } [target.'cfg(not(target_family = "wasm"))'.dependencies] libc = "0.2.101" async-std = { version = "1.12.0", features = ["attributes", "unstable"] } -async-tungstenite = { version = "0.25", features = [ - "async-std-runtime", - "async-tls", -] } +async-tungstenite = { version = "0.25", features = ["async-std-runtime"] } async-io = "2.2.0" # Transit @@ -103,6 +100,11 @@ forwarding = ["transit", "rmp-serde"] default = ["transit", "transfer"] all = ["default", "forwarding"] +# TLS implementations for websocket connections via async-tungstenite +# required for optional wss connection to the mailbox server +tls = ["async-tungstenite/async-tls"] +native-tls = ["async-tungstenite/async-native-tls"] + [profile.release] overflow-checks = true strip = "debuginfo" From 7366377c9725228c7fc56bc57dd9046103e59e96 Mon Sep 17 00:00:00 2001 From: Fina Wilke Date: Mon, 22 Apr 2024 17:06:08 +0200 Subject: [PATCH 2/2] code: Format with cargo fmt --- src/core/test.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/test.rs b/src/core/test.rs index 1647a27a..4a994690 100644 --- a/src/core/test.rs +++ b/src/core/test.rs @@ -183,7 +183,8 @@ pub async fn test_file_rust2rust_deprecated() -> eyre::Result<()> { .name("sender".to_owned()) .spawn(async { let (welcome, wormhole_future) = - Wormhole::connect_without_code(transfer::APP_CONFIG.id(TEST_APPID).clone(), 2).await?; + Wormhole::connect_without_code(transfer::APP_CONFIG.id(TEST_APPID).clone(), 2) + .await?; if let Some(welcome) = &welcome.welcome { log::info!("Got welcome: {}", welcome); } @@ -258,7 +259,8 @@ pub async fn test_file_rust2rust() -> eyre::Result<()> { .name("sender".to_owned()) .spawn(async { let mailbox_connection = - MailboxConnection::create(transfer::APP_CONFIG.id(TEST_APPID).clone(), 2).await?; + MailboxConnection::create(transfer::APP_CONFIG.id(TEST_APPID).clone(), 2) + .await?; if let Some(welcome) = &mailbox_connection.welcome { log::info!("Got welcome: {}", welcome); }