reconfigure [features] tls rootCA & websocket

This commit is contained in:
nworbnhoj 2023-06-28 05:56:41 +10:00
parent 0e85ff2aac
commit b8b591401f
3 changed files with 17 additions and 10 deletions

View file

@ -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"]

View file

@ -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 = []

View file

@ -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<net::protocols::Ping>,
#[cfg(feature="tls")]
#[cfg(feature = "websocket")]
ws: Option<WebSocket<MaybeTlsStream<TcpStream>>>,
#[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 <host> 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<Item = &'a str>) {
use core::fmt::Write;
for (i, tok) in tokens.enumerate() {