Client: option skip verif

This commit is contained in:
Pascal Engélibert 2026-03-02 12:03:53 +01:00
commit c19ca3c7d1
2 changed files with 10 additions and 4 deletions

View file

@ -95,6 +95,7 @@ pub async fn play(
connect_to: (String, u16), connect_to: (String, u16),
repeat: u32, repeat: u32,
cert_path: Option<&str>, cert_path: Option<&str>,
skip_verif: bool,
debug: bool, debug: bool,
) { ) {
// Semaphore used to limit the number of concurrent clients. // 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 running = Arc::new(Mutex::new(HashSet::new()));
let total = records.len() * repeat as usize; let total = records.len() * repeat as usize;
let connect_to = connect_to.to_socket_addrs().unwrap().next().unwrap(); 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]); let dummy_bytes = Arc::new(vec![0x42u8; 16 * 1024 * 1024]);
@ -130,7 +130,11 @@ pub async fn play(
if use_tls { if use_tls {
let config_builder = tokio_rustls::rustls::ClientConfig::builder(); 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(); let mut certs = tokio_rustls::rustls::RootCertStore::empty();
for file in std::fs::read_dir(cert_path).unwrap_or_else(|e| { for file in std::fs::read_dir(cert_path).unwrap_or_else(|e| {
panic!("Cannot read certificate directory `{cert_path}`: {e:?}") panic!("Cannot read certificate directory `{cert_path}`: {e:?}")
@ -165,8 +169,6 @@ pub async fn play(
config_builder.with_root_certificates(certs) config_builder.with_root_certificates(certs)
} else { } else {
config_builder.with_platform_verifier().unwrap() config_builder.with_platform_verifier().unwrap()
//.dangerous()
//.with_custom_certificate_verifier(Arc::new(DummyCertVerifier))
} }
.with_no_client_auth(); .with_no_client_auth();
let mut enable_early_data = false; let mut enable_early_data = false;

View file

@ -64,6 +64,9 @@ struct OptClient {
/// Path to PEM certificates (if not provided, use system's certificates) /// Path to PEM certificates (if not provided, use system's certificates)
#[argp(option, short = 'c')] #[argp(option, short = 'c')]
certs: Option<String>, certs: Option<String>,
/// Do not verify certificates
#[argp(option, short = 's')]
skip_verif: bool,
/// Print debug info /// Print debug info
#[argp(switch, short = 'd')] #[argp(switch, short = 'd')]
debug: bool, debug: bool,
@ -146,6 +149,7 @@ async fn main() {
(subopt.connect_addr, subopt.connect_port), (subopt.connect_addr, subopt.connect_port),
subopt.repeat, subopt.repeat,
subopt.certs.as_deref(), subopt.certs.as_deref(),
subopt.skip_verif,
subopt.debug, subopt.debug,
) )
.await; .await;