mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-04 04:27:34 +00:00
add some test code to exercise TLS to break the linking
This commit is contained in:
parent
a8f2c99b6c
commit
a05ab47d10
3 changed files with 55 additions and 3 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
|
@ -2821,10 +2821,14 @@ dependencies = [
|
|||
"cc",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"rkyv",
|
||||
"spin 0.5.2",
|
||||
"untrusted",
|
||||
"web-sys",
|
||||
"winapi",
|
||||
"xous",
|
||||
"xous-ipc 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xous-names",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3256,6 +3260,7 @@ dependencies = [
|
|||
"tts-frontend",
|
||||
"usb-device-xous",
|
||||
"utralib",
|
||||
"webpki-roots",
|
||||
"x25519-dalek",
|
||||
"xous",
|
||||
"xous-ipc 0.9.7",
|
||||
|
|
@ -4276,9 +4281,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "0.22.3"
|
||||
version = "0.22.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44d8de8415c823c8abd270ad483c6feeac771fad964890779f9a8cb24fbbc1bf"
|
||||
checksum = "f1c760f0d366a6c24a02ed7816e23e691f5d92291f94d15e836006fd11b04daf"
|
||||
dependencies = [
|
||||
"webpki 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ tracing-subscriber = {version = "0.3.11", optional = true}
|
|||
# for rustls testing
|
||||
#rustls = "0.20.6"
|
||||
rustls = {path="../../../rustls/rustls"}
|
||||
webpki-roots = "0.22.4"
|
||||
|
||||
# for the curve25519 tests
|
||||
# hardware acceleration adaptations are inserted into a fork of the main branch.
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use dns::Dns; // necessary to work around https://github.com/rust-lang/rust/issu
|
|||
use std::str::FromStr;
|
||||
#[cfg(feature="ditherpunk")]
|
||||
use gam::DecodePng;
|
||||
use std::convert::TryInto;
|
||||
|
||||
pub struct NetCmd {
|
||||
callback_id: Option<u32>,
|
||||
|
|
@ -385,7 +386,52 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
|
|||
}
|
||||
}
|
||||
"tls" => {
|
||||
write!(ret, "Work in progress. Please check back later!").unwrap();
|
||||
let mut root_store = rustls::RootCertStore::empty();
|
||||
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,
|
||||
)
|
||||
})
|
||||
);
|
||||
let config = rustls::ClientConfig::builder()
|
||||
.with_safe_defaults()
|
||||
.with_root_certificates(root_store)
|
||||
.with_no_client_auth();
|
||||
|
||||
let server_name = "bunniefoo.com".try_into().unwrap();
|
||||
let mut conn = rustls::ClientConnection::new(Arc::new(config), server_name).unwrap();
|
||||
|
||||
let mut sock = TcpStream::connect("google.com:443").unwrap();
|
||||
let mut tls = rustls::Stream::new(&mut conn, &mut sock);
|
||||
tls.write_all(
|
||||
concat!(
|
||||
"GET / HTTP/1.1\r\n",
|
||||
"Host: bunniefoo.com\r\n",
|
||||
"Connection: close\r\n",
|
||||
"Accept-Encoding: identity\r\n",
|
||||
"\r\n"
|
||||
)
|
||||
.as_bytes(),
|
||||
)
|
||||
.unwrap();
|
||||
let ciphersuite = tls
|
||||
.conn
|
||||
.negotiated_cipher_suite()
|
||||
.unwrap();
|
||||
log::info!(
|
||||
"Current ciphersuite: {:?}",
|
||||
ciphersuite.suite()
|
||||
);
|
||||
let mut plaintext = Vec::new();
|
||||
tls.read_to_end(&mut plaintext).unwrap();
|
||||
log::info!("len: {}", plaintext.len());
|
||||
log::info!("{}", std::str::from_utf8(&plaintext).unwrap_or("utf-error"));
|
||||
}
|
||||
#[cfg(any(target_os = "none", target_os = "xous"))]
|
||||
"ping" => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue