From a741e7988ba1e1b136a8f61fa7d2221c19405800 Mon Sep 17 00:00:00 2001 From: nworbnhoj Date: Mon, 26 Jun 2023 08:12:11 +1000 Subject: [PATCH] tidy-up tls cargo & use --- libs/tls/Cargo.toml | 2 +- libs/tls/src/lib.rs | 2 +- services/shellchat/Cargo.toml | 15 +++++--- services/shellchat/src/cmds/net_cmd.rs | 48 +++++++++++++++----------- 4 files changed, 40 insertions(+), 27 deletions(-) diff --git a/libs/tls/Cargo.toml b/libs/tls/Cargo.toml index 39a939290..2cd2ddb98 100644 --- a/libs/tls/Cargo.toml +++ b/libs/tls/Cargo.toml @@ -20,5 +20,5 @@ net = { path = "../../services/net" } pddb = { path = "../../services/pddb" } rkyv = "0.4.3" -rustls = "0.21.2" +rustls = { version = "0.21.2", features = ["dangerous_configuration"]} x509-parser = "0.15.0" diff --git a/libs/tls/src/lib.rs b/libs/tls/src/lib.rs index 3736c99b4..58bf90b66 100644 --- a/libs/tls/src/lib.rs +++ b/libs/tls/src/lib.rs @@ -7,7 +7,7 @@ use rkyv::{ AlignedVec, Archive, Deserialize, Serialize, }; use rustls::{Certificate, DistinguishedName, RootCertStore}; -use std::convert::TryFrom; +use std::cmp::min; use std::convert::{Into, TryFrom}; use std::fs::File; use std::io::{Error, ErrorKind, Read, Write}; diff --git a/services/shellchat/Cargo.toml b/services/shellchat/Cargo.toml index 81f0aa91d..49da17b27 100644 --- a/services/shellchat/Cargo.toml +++ b/services/shellchat/Cargo.toml @@ -76,12 +76,19 @@ tracing-subscriber = {version = "0.3.11", optional = true} # for rustls testing tls = {path="../../libs/tls"} -rustls = {version = "0.21.2", optional = true} # note requirement for patch to xous-ring in workspace Cargo.toml -# rustls = {path="../../../rustls/rustls"} + +# note requirement for patch to xous-ring in workspace Cargo.toml +rustls = {version = "0.21.2", optional = true} webpki-roots = {version = "0.22.4", optional = true} -ring = {version = "0.16.20", optional = true} # for testing ring math functions # note requirement for patch to xous-ring in workspace Cargo.toml -tungstenite = {version = "0.17.3", optional = true, features = ["rustls-tls-webpki-roots"]} url = {version = "2.2.2", optional = true} +x509-parser = "0.15.0" + +# for testing ring math functions +# note requirement for patch to xous-ring in workspace Cargo.toml +ring = {version = "0.16.20", optional = true} + +# for websocket testing +tungstenite = {version = "0.17.3", optional = true, features = ["rustls-tls-webpki-roots"]} # for performance testing perflib = {path="../../tools/perflib", optional = true} diff --git a/services/shellchat/src/cmds/net_cmd.rs b/services/shellchat/src/cmds/net_cmd.rs index b5f4346d7..abd45f128 100644 --- a/services/shellchat/src/cmds/net_cmd.rs +++ b/services/shellchat/src/cmds/net_cmd.rs @@ -1,30 +1,36 @@ -use crate::{ShellCmdApi, CommonEnv}; +use crate::{CommonEnv, ShellCmdApi}; use com::api::NET_MTU; -use xous_ipc::String; -#[cfg(any(feature="precursor", feature="renode"))] -use net::XousServerId; use net::NetPingCallback; -use xous::MessageEnvelope; use num_traits::*; -use std::net::{IpAddr, TcpStream, TcpListener}; -use std::io::Write; -#[cfg(feature = "tls")] -use rustls::{Certificate, OwnedTrustAnchor}; +use rustls::internal::msgs::base::PayloadU16; +use rustls::internal::msgs::handshake::DistinguishedName; use std::io::Read; -use std::sync::{Arc, Mutex}; -use std::time::{Duration, Instant}; -use std::thread; +use std::io::Write; +use std::net::{IpAddr, TcpListener, TcpStream}; use std::sync::mpsc; -#[cfg(feature="ditherpunk")] -use std::str::FromStr; -#[cfg(feature="ditherpunk")] -use gam::DecodePng; -#[cfg(feature="tls")] -use std::convert::TryInto; -#[cfg(feature="tls")] -use tungstenite::{WebSocket, stream::MaybeTlsStream}; -#[cfg(feature="shellperf")] +use std::sync::{Arc, Mutex}; +use std::thread; +use std::time::{Duration, Instant}; +use xous::MessageEnvelope; +use xous_ipc::String; + +#[cfg(feature = "ditherpunk")] +use {gam::DecodePng, std::str::FromStr}; + +#[cfg(any(feature = "precursor", feature = "renode"))] +use net::XousServerId; + +#[cfg(feature = "shellperf")] use perflib::*; + +#[cfg(feature = "tls")] +use { + rustls::{Certificate, OwnedTrustAnchor}, + std::convert::TryInto, + tls::{danger, Trusted}, + tungstenite::{stream::MaybeTlsStream, WebSocket}, +}; + pub struct NetCmd { callback_id: Option, callback_conn: u32,