diff --git a/src/client.rs b/src/client.rs index b2dd267..219e9eb 100644 --- a/src/client.rs +++ b/src/client.rs @@ -95,6 +95,7 @@ pub async fn play( connect_to: (String, u16), repeat: u32, cert_path: Option<&str>, + skip_verif: bool, debug: bool, ) { // Semaphore used to limit the number of concurrent clients. @@ -104,7 +105,6 @@ pub async fn play( let running = Arc::new(Mutex::new(HashSet::new())); let total = records.len() * repeat as usize; let connect_to = connect_to.to_socket_addrs().unwrap().next().unwrap(); - let debug_mutex = Arc::new(Mutex::new(())); let dummy_bytes = Arc::new(vec![0x42u8; 16 * 1024 * 1024]); @@ -130,7 +130,11 @@ pub async fn play( if use_tls { let config_builder = tokio_rustls::rustls::ClientConfig::builder(); - let mut config = if let Some(cert_path) = cert_path { + let mut config = if skip_verif { + config_builder + .dangerous() + .with_custom_certificate_verifier(Arc::new(DummyCertVerifier)) + } else if let Some(cert_path) = cert_path { let mut certs = tokio_rustls::rustls::RootCertStore::empty(); for file in std::fs::read_dir(cert_path).unwrap_or_else(|e| { panic!("Cannot read certificate directory `{cert_path}`: {e:?}") @@ -165,8 +169,6 @@ pub async fn play( config_builder.with_root_certificates(certs) } else { config_builder.with_platform_verifier().unwrap() - //.dangerous() - //.with_custom_certificate_verifier(Arc::new(DummyCertVerifier)) } .with_no_client_auth(); let mut enable_early_data = false; diff --git a/src/main.rs b/src/main.rs index 392e2a8..58830a8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,6 +64,9 @@ struct OptClient { /// Path to PEM certificates (if not provided, use system's certificates) #[argp(option, short = 'c')] certs: Option, + /// Do not verify certificates + #[argp(option, short = 's')] + skip_verif: bool, /// Print debug info #[argp(switch, short = 'd')] debug: bool, @@ -146,6 +149,7 @@ async fn main() { (subopt.connect_addr, subopt.connect_port), subopt.repeat, subopt.certs.as_deref(), + subopt.skip_verif, subopt.debug, ) .await;