Disable resumption

This commit is contained in:
Pascal Engélibert 2025-12-01 17:04:06 +01:00
commit 9bb6e4fe9d
5 changed files with 152 additions and 10 deletions

View file

@ -18,7 +18,10 @@ use tokio_rustls::{
TlsConnector,
rustls::{
SignatureScheme,
client::danger::{HandshakeSignatureValid, ServerCertVerifier},
client::{
Resumption,
danger::{HandshakeSignatureValid, ServerCertVerifier},
},
pki_types::ServerName,
},
};
@ -98,12 +101,12 @@ pub async fn play(
let connect_to = connect_to.to_socket_addrs().unwrap().next().unwrap();
match tls_mode {
TlsMode::Both | TlsMode::Client => {
let config = Arc::new(
tokio_rustls::rustls::ClientConfig::builder()
.dangerous()
.with_custom_certificate_verifier(Arc::new(DummyCertVerifier))
.with_no_client_auth(),
);
let mut config = tokio_rustls::rustls::ClientConfig::builder()
.dangerous()
.with_custom_certificate_verifier(Arc::new(DummyCertVerifier))
.with_no_client_auth();
config.resumption = Resumption::disabled();
let config = Arc::new(config);
for (id, (server_name, records)) in records.iter() {
let connector = TlsConnector::from(config.clone());
let counter = counter.clone();
@ -250,7 +253,7 @@ pub async fn play(
for (direction, data) in records {
match direction {
Direction::ClientToServer => {
//println!("[CLT] ({id}) >> {}", data.len());
//println!("[CLT] ({id}) >> {}", str::from_utf8(&data[..data.len().min(255)]).unwrap());
//stream.get_mut().write_all(data).await.unwrap();
match tokio::time::timeout(
std::time::Duration::from_millis(1000),
@ -267,7 +270,7 @@ pub async fn play(
//let mut buf = Vec::new();
//stream.read_buf(&mut buf).await.ok();
//let mut buf = vec![0; data.len().saturating_sub(50).max(1)];
match tokio::time::timeout(
let resp = match tokio::time::timeout(
std::time::Duration::from_millis(1000),
stream.next(),
)

View file

@ -94,6 +94,7 @@ static RECORDS: StaticCell<Records> = StaticCell::new();
#[tokio::main]
async fn main() {
env_logger::init();
let opt: Opt = argp::parse_args_or_exit(argp::DEFAULT);
match opt.subcommand {

View file

@ -182,7 +182,12 @@ pub async fn play(
};*/
let fut = async move {
let accepted = acceptor.await.unwrap();
let server_name = accepted.client_hello().server_name().unwrap().to_string();
let server_name = accepted
.client_hello()
.server_name()
.unwrap()
.trim_end_matches(".localhost")
.to_string();
let stream = accepted.into_stream(config).await.unwrap();
let mut stream = Framed::new(stream, crate::http::HttpCodec {});
let req = stream.next().await.unwrap().unwrap();
@ -270,6 +275,7 @@ pub async fn play(
//println!("[SRV] New task");
let mut stream = Framed::new(stream, crate::http::HttpCodec {});
let req = stream.next().await.unwrap().unwrap();
//println!("[SRV] << {}", str::from_utf8(&req[..req.len().min(255)]).unwrap());
let req_hash = tlsh::hash_buf(&req)
.map_or_else(|_| req.clone(), |h| h.to_string().into_bytes());
let mut best = None;