From 18f7989e2830970e3d8d6a646bb84bfc706c5f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Eng=C3=A9libert?= Date: Wed, 26 Aug 2026 14:24:33 +0200 Subject: [PATCH] Timeout adjustments, random serial number --- src/record.rs | 10 +++++++++- src/server.rs | 8 ++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/record.rs b/src/record.rs index 5ba5317..cefb74d 100644 --- a/src/record.rs +++ b/src/record.rs @@ -202,8 +202,16 @@ impl LyingCertificateRegistry { ) .unwrap(); cert_builder.set_not_before(cert.not_before()).unwrap(); + let mut serial = openssl::bn::BigNum::new().unwrap(); + serial + .rand(160, openssl::bn::MsbOption::MAYBE_ZERO, false) + .unwrap(); cert_builder - .set_serial_number(cert.serial_number()) + .set_serial_number( + openssl::asn1::Asn1Integer::from_bn(&serial.as_ref()) + .unwrap() + .as_ref(), + ) .unwrap(); cert_builder.set_subject_name(cert.subject_name()).unwrap(); cert_builder.set_version(cert.version()).unwrap(); diff --git a/src/server.rs b/src/server.rs index 67f3ce0..7a12f98 100644 --- a/src/server.rs +++ b/src/server.rs @@ -221,7 +221,7 @@ pub async fn play( //let mut previous = Vec::new(); loop { let req = match tokio::time::timeout( - tokio::time::Duration::from_secs(5), + tokio::time::Duration::from_secs(10), stream.next(), ) .await @@ -274,7 +274,7 @@ pub async fn play( break; } } - stream.get_mut().shutdown().await.unwrap(); + stream.get_mut().shutdown().await.ok(); }; tokio::spawn(async move { fut.await; @@ -297,7 +297,7 @@ pub async fn play( //let mut previous = Vec::new(); loop { let Ok(req) = - tokio::time::timeout(tokio::time::Duration::from_secs(5), stream.next()) + tokio::time::timeout(tokio::time::Duration::from_secs(10), stream.next()) .await else { if break_next { @@ -346,7 +346,7 @@ pub async fn play( } } //println!("Server shutdown"); - stream.get_mut().shutdown().await.unwrap(); + stream.get_mut().shutdown().await.ok(); }; // Using a variable for the future allows it to be detected by tokio-console tokio::spawn(async move {