From b8b591401fb84d68ec1a9b22b9d2ac805c0370cb Mon Sep 17 00:00:00 2001 From: nworbnhoj Date: Wed, 28 Jun 2023 05:56:41 +1000 Subject: [PATCH] reconfigure `[features]` `tls` `rootCA` & `websocket` --- libs/tls/Cargo.toml | 5 ++++- services/shellchat/Cargo.toml | 6 ++++-- services/shellchat/src/cmds/net_cmd.rs | 16 +++++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libs/tls/Cargo.toml b/libs/tls/Cargo.toml index a17c2fa31..6311e3f60 100644 --- a/libs/tls/Cargo.toml +++ b/libs/tls/Cargo.toml @@ -24,5 +24,8 @@ rkyv = "0.4.3" # note requirement for patch to xous-ring in workspace Cargo.toml rustls = { version = "0.21.2", features = ["dangerous_configuration"] } webpki = { package = "rustls-webpki", version = "0.100.1" } -webpki-roots = {version = "0.23.1" } +webpki-roots = {version = "0.23.1", optional = true} x509-parser = "0.15.0" + +[features] +rootCA = ["webpki-roots"] diff --git a/services/shellchat/Cargo.toml b/services/shellchat/Cargo.toml index 71148d00c..80291cfeb 100644 --- a/services/shellchat/Cargo.toml +++ b/services/shellchat/Cargo.toml @@ -75,7 +75,7 @@ tracing = {version = "0.1.35", optional = true} tracing-subscriber = {version = "0.3.11", optional = true} # for rustls testing -tls = {path="../../libs/tls"} +tls = {path = "../../libs/tls", optional = true} url = {version = "2.2.2", optional = true} # for testing ring math functions # note requirement for patch to xous-ring in workspace Cargo.toml @@ -126,7 +126,9 @@ dbg-ecupdate = [] # for issuing manual commands to initiate an EC update (vs UX) test-rekey = [] no-codec = [] nettest = [] # batch network tests -tls = ["ring", "tungstenite", "url"] +tls = ["dep:tls"] +rootCA = ["tls/rootCA"] +websocket = ["tls", "tungstenite", "url"] shellperf = ["ring", "perflib", "xous/v2p", "random-pick"] # this also needs the project-wide "perfcounter" feature to be selected. shellchat is the exclusive manager of the performance counter, do not use with e.g. "vaultperf" feature extra-tests = [] mass-storage = [] diff --git a/services/shellchat/src/cmds/net_cmd.rs b/services/shellchat/src/cmds/net_cmd.rs index af900950f..fdb82e4ae 100644 --- a/services/shellchat/src/cmds/net_cmd.rs +++ b/services/shellchat/src/cmds/net_cmd.rs @@ -23,7 +23,7 @@ use net::XousServerId; #[cfg(feature = "shellperf")] use perflib::*; -#[cfg(feature = "tls")] +#[cfg(feature = "websocket")] use tungstenite::{stream::MaybeTlsStream, WebSocket}; pub struct NetCmd { @@ -32,7 +32,7 @@ pub struct NetCmd { dns: dns::Dns, #[cfg(any(feature="precursor", feature="renode"))] ping: Option, - #[cfg(feature="tls")] + #[cfg(feature = "websocket")] ws: Option>>, #[cfg(feature="shellperf")] perfbuf: xous::MemoryRange, @@ -53,7 +53,7 @@ impl NetCmd { dns: dns::Dns::new(&xns).unwrap(), #[cfg(any(feature="precursor", feature="renode"))] ping: None, - #[cfg(feature="tls")] + #[cfg(feature = "websocket")] ws: None, #[cfg(feature="shellperf")] perfbuf, @@ -414,7 +414,7 @@ impl<'a> ShellCmdApi<'a> for NetCmd { ring::xous_test::p256_elem_add_test(); log::set_max_level(log::LevelFilter::Info); } - #[cfg(feature="tls")] + #[cfg(feature = "websocket")] "ws" => { if self.ws.is_none() { let (socket, response) = @@ -460,8 +460,10 @@ impl<'a> ShellCmdApi<'a> for NetCmd { // test make tls connection to host // trusted list trusted CA certificates #[cfg(feature = "tls")] - "tls" => if let Ok(Some(r)) = tls::cmd::shellchat(&mut tokens) { - write!(ret, "{r}").unwrap(); + "tls" => { + if let Ok(Some(r)) = tls::cmd::shellchat(&mut tokens) { + write!(ret, "{r}").unwrap(); + } } // note: to use the `shellperf` option, you need to load a version of the SOC that has the performance counters built in. // this can be generated using the command `python3 .\betrusted_soc.py -e .\dummy.nky --perfcounter` in the betrusted-soc repo. @@ -886,7 +888,7 @@ fn heap_usage() -> usize { } } -#[cfg(feature ="tls")] +#[cfg(feature = "websocket")] fn join_tokens<'a>(buf: &mut String<1024>, tokens: impl Iterator) { use core::fmt::Write; for (i, tok) in tokens.enumerate() {