Skip to content

Commit

Permalink
tests: don't overfit on RSA private keys
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cpu committed Jul 12, 2024
1 parent d1f37bd commit d81328b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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()
Expand Down

0 comments on commit d81328b

Please sign in to comment.