From 7fdd067e04c9033b21bcf094c395c33ed4ad0c49 Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Fri, 12 Jul 2024 09:20:45 -0400 Subject: [PATCH] tests: don't overfit on RSA private keys Prefer `rustls_pemfile::private_key()` to `rsa_private_keys()`. The former is more general, and also doesn't require the `next()` dance that `rsa_private_keys()` does if you're only interested in one private key. --- tests/utils.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/utils.rs b/tests/utils.rs index 06f3f82..04923f3 100644 --- a/tests/utils.rs +++ b/tests/utils.rs @@ -2,7 +2,7 @@ mod utils { use std::io::{BufReader, Cursor, IoSlice}; use rustls::{ClientConfig, RootCertStore, ServerConfig}; - use rustls_pemfile::{certs, rsa_private_keys}; + use rustls_pemfile::{certs, private_key}; use tokio::io::{self, AsyncWrite, AsyncWriteExt}; #[allow(dead_code)] @@ -14,8 +14,7 @@ mod utils { let cert = certs(&mut BufReader::new(Cursor::new(CERT))) .map(|result| result.unwrap()) .collect(); - let key = rsa_private_keys(&mut BufReader::new(Cursor::new(RSA))) - .next() + let key = private_key(&mut BufReader::new(Cursor::new(RSA))) .unwrap() .unwrap(); let sconfig = ServerConfig::builder()