From a2e1407578215402c26df7525fce2884109f218c Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 17 Jan 2024 19:08:38 +0100 Subject: [PATCH] Update Rustls dependencies --- rust/Cargo.lock | 133 ++++++++++++++++------- rust/sea_battle_cli_player/Cargo.toml | 7 +- rust/sea_battle_cli_player/src/client.rs | 9 +- 3 files changed, 101 insertions(+), 48 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index dfccd8f..a911f33 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1058,10 +1058,10 @@ dependencies = [ "http 0.2.11", "hyper", "log", - "rustls", - "rustls-native-certs", + "rustls 0.21.10", + "rustls-native-certs 0.6.3", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", ] [[package]] @@ -1554,14 +1554,14 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", - "rustls-pemfile", + "rustls 0.21.10", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", "system-configuration", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tower-service", "url", "wasm-bindgen", @@ -1621,10 +1621,24 @@ checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.1", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -1632,7 +1646,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.4", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.0.0", + "rustls-pki-types", "schannel", "security-framework", ] @@ -1646,6 +1673,22 @@ dependencies = [ "base64", ] +[[package]] +name = "rustls-pemfile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e4980fa29e4c4b212ffb3db068a564cbf560e51d3944b7c88bd8bf5bec64f4" +dependencies = [ + "base64", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9d979b3ce68192e42760c7810125eb6cf2ea10efae545a156063e61f314e2a" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -1656,6 +1699,17 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustls-webpki" +version = "0.102.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef4ca26037c909dedb327b48c3327d0ba91d3dd3c4e05dad328f210ffb68e95b" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "ryu" version = "1.0.16" @@ -1707,7 +1761,7 @@ dependencies = [ "serde_urlencoded", "serde_with", "tokio", - "tokio-tungstenite 0.21.0", + "tokio-tungstenite", "uuid", ] @@ -1727,13 +1781,14 @@ dependencies = [ "num-derive", "num-traits", "reqwest", - "rustls", + "rustls 0.22.2", + "rustls-native-certs 0.7.0", "sea_battle_backend", "serde_json", "serde_urlencoded", "textwrap", "tokio", - "tokio-tungstenite 0.20.1", + "tokio-tungstenite", "tui", ] @@ -1922,6 +1977,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + [[package]] name = "syn" version = "1.0.109" @@ -2085,23 +2146,19 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.10", "tokio", ] [[package]] -name = "tokio-tungstenite" -version = "0.20.1" +name = "tokio-rustls" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "futures-util", - "log", - "rustls", - "rustls-native-certs", + "rustls 0.22.2", + "rustls-pki-types", "tokio", - "tokio-rustls", - "tungstenite 0.20.1", ] [[package]] @@ -2112,8 +2169,12 @@ checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" dependencies = [ "futures-util", "log", + "rustls 0.22.2", + "rustls-native-certs 0.7.0", + "rustls-pki-types", "tokio", - "tungstenite 0.21.0", + "tokio-rustls 0.25.0", + "tungstenite", ] [[package]] @@ -2175,26 +2236,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "tungstenite" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 0.2.11", - "httparse", - "log", - "rand", - "rustls", - "sha1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "tungstenite" version = "0.21.0" @@ -2208,6 +2249,8 @@ dependencies = [ "httparse", "log", "rand", + "rustls 0.22.2", + "rustls-pki-types", "sha1", "thiserror", "url", @@ -2602,6 +2645,12 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" + [[package]] name = "zstd" version = "0.13.0" diff --git a/rust/sea_battle_cli_player/Cargo.toml b/rust/sea_battle_cli_player/Cargo.toml index bcbae69..64bebb6 100644 --- a/rust/sea_battle_cli_player/Cargo.toml +++ b/rust/sea_battle_cli_player/Cargo.toml @@ -24,11 +24,12 @@ num = "0.4.1" num-traits = "0.2.17" num-derive = "0.4.1" textwrap = "0.16.0" -tokio-tungstenite = { version = "0.20.1", features = ["__rustls-tls", "rustls-tls-native-roots"] } +tokio-tungstenite = { version = "0.21.0", features = ["__rustls-tls", "rustls-tls-native-roots"] } serde_urlencoded = "0.7.1" futures = "0.3.30" serde_json = "1.0.110" hostname = "0.3.1" -rustls = "0.21.9" +rustls = "0.22.0" hyper-rustls = { version = "0.24.2", features = ["rustls-native-certs"] } -reqwest = { version = "0.11", features = ["json", "rustls-tls"], default-features = false } \ No newline at end of file +reqwest = { version = "0.11", features = ["json", "rustls-tls"], default-features = false } +rustls-native-certs = {version = "0.7.0"} \ No newline at end of file diff --git a/rust/sea_battle_cli_player/src/client.rs b/rust/sea_battle_cli_player/src/client.rs index 2155048..1635a56 100644 --- a/rust/sea_battle_cli_player/src/client.rs +++ b/rust/sea_battle_cli_player/src/client.rs @@ -2,7 +2,6 @@ use crate::cli_args::cli_args; use crate::server; use futures::stream::{SplitSink, SplitStream}; use futures::{SinkExt, StreamExt}; -use hyper_rustls::ConfigBuilderExt; use sea_battle_backend::data::*; use sea_battle_backend::human_player_ws::{ClientMessage, ServerMessage}; use sea_battle_backend::server::{ @@ -127,9 +126,13 @@ impl Client { let (socket, _) = if ws_url.starts_with("wss") { // Perform a connection over TLS + let mut roots = rustls::RootCertStore::empty(); + for cert in rustls_native_certs::load_native_certs()? { + roots.add(cert).unwrap(); + } + let config = rustls::ClientConfig::builder() - .with_safe_defaults() - .with_native_roots() + .with_root_certificates(roots) .with_no_client_auth(); let connector = tokio_tungstenite::Connector::Rustls(Arc::new(config));