demote shellchat "net tls" to "net tls test"

This commit is contained in:
nworbnhoj 2023-06-20 20:48:58 +10:00
parent 8d12e3d8d3
commit e6ed977065

View file

@ -453,6 +453,20 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
} }
#[cfg(feature = "tls")] #[cfg(feature = "tls")]
"tls" => { "tls" => {
if let Some(tls_cmd) = tokens.next() {
match tls_cmd {
let mut root_store = rustls::RootCertStore::empty();
log::info!("create root store");
root_store.add_server_trust_anchors(
webpki_roots::TLS_SERVER_ROOTS
.0
.iter()
.map(|ta| {
rustls::OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject,
ta.spki,
ta.name_constraints,
"test" => {
log::set_max_level(log::LevelFilter::Info); log::set_max_level(log::LevelFilter::Info);
log::info!("starting TLS run"); log::info!("starting TLS run");
let mut root_store = rustls::RootCertStore::empty(); let mut root_store = rustls::RootCertStore::empty();
@ -477,7 +491,9 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
log::info!("point TLS to bunniefoo.com"); log::info!("point TLS to bunniefoo.com");
let server_name = "bunniefoo.com".try_into().unwrap(); let server_name = "bunniefoo.com".try_into().unwrap();
let mut conn = rustls::ClientConnection::new(Arc::new(config), server_name).unwrap(); let mut conn =
rustls::ClientConnection::new(Arc::new(config), server_name)
.unwrap();
log::info!("connect TCPstream to bunniefoo.com"); log::info!("connect TCPstream to bunniefoo.com");
let mut sock = TcpStream::connect("bunniefoo.com:443").unwrap(); let mut sock = TcpStream::connect("bunniefoo.com:443").unwrap();
@ -495,21 +511,24 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
) )
.unwrap(); .unwrap();
log::info!("readout cipher suite"); log::info!("readout cipher suite");
let ciphersuite = tls let ciphersuite = tls.conn.negotiated_cipher_suite().unwrap();
.conn log::info!("Current ciphersuite: {:?}", ciphersuite.suite());
.negotiated_cipher_suite()
.unwrap();
log::info!(
"Current ciphersuite: {:?}",
ciphersuite.suite()
);
let mut plaintext = Vec::new(); let mut plaintext = Vec::new();
log::info!("read TLS response"); log::info!("read TLS response");
tls.read_to_end(&mut plaintext).unwrap(); tls.read_to_end(&mut plaintext).unwrap();
log::info!("len: {}", plaintext.len()); log::info!("len: {}", plaintext.len());
log::info!("{}", std::str::from_utf8(&plaintext).unwrap_or("utf-error")); log::info!(
"{}",
std::str::from_utf8(&plaintext).unwrap_or("utf-error")
);
log::set_max_level(log::LevelFilter::Info); log::set_max_level(log::LevelFilter::Info);
} }
_ => {
write!(ret, "net commands: test").ok();
}
}
}
}
// note: to use the `shellperf` option, you need to load a version of the SOC that has the performance counters built in. // 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. // this can be generated using the command `python3 .\betrusted_soc.py -e .\dummy.nky --perfcounter` in the betrusted-soc repo.
// //