Skip to content

Commit b90397c

Browse files
authored
Merge pull request #284 from influxdata/crepererum/RUSTSEC-2025-0134
chore: replace `rustls-pemfile` w/ `rustls-pki-types`
2 parents 5011a3c + 83e251b commit b90397c

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ futures = "0.3"
4646
j4rs = "0.23.1"
4747
proptest = "1"
4848
proptest-derive = "0.7"
49-
rustls-pemfile = "2.0"
49+
rustls-pki-types = "1.11"
5050
rdkafka = { version = "0.38", default-features = false, features = ["libz", "tokio", "zstd"] }
5151
tokio = { version = "1.14", features = ["macros", "rt-multi-thread"] }
5252
tracing-log = "0.2"

tests/client.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,36 +209,44 @@ async fn test_non_existing_partition() {
209209
#[tokio::test]
210210
#[cfg(feature = "transport-tls")]
211211
async fn test_tls() {
212+
use rustls_pki_types::{
213+
PrivateKeyDer,
214+
pem::{PemObject, SectionKind},
215+
};
216+
212217
maybe_start_logging();
213218

214219
let mut root_store = rustls::RootCertStore::empty();
215220

216221
let file = std::fs::File::open("/tmp/cluster-ca.crt").unwrap();
217222
let mut reader = std::io::BufReader::new(file);
218-
match rustls_pemfile::read_one(&mut reader).unwrap().unwrap() {
219-
rustls_pemfile::Item::X509Certificate(key) => {
220-
root_store.add(key).unwrap();
223+
match rustls_pki_types::pem::from_buf(&mut reader)
224+
.unwrap()
225+
.unwrap()
226+
{
227+
(SectionKind::Certificate, data) => {
228+
root_store.add(data.into()).unwrap();
221229
}
222230
_ => unreachable!(),
223231
}
224232

225233
let file = std::fs::File::open("/tmp/ca.crt").unwrap();
226234
let mut reader = std::io::BufReader::new(file);
227-
let producer_root = match rustls_pemfile::read_one(&mut reader).unwrap().unwrap() {
228-
rustls_pemfile::Item::X509Certificate(key) => key,
235+
let producer_root = match rustls_pki_types::pem::from_buf(&mut reader)
236+
.unwrap()
237+
.unwrap()
238+
{
239+
(SectionKind::Certificate, data) => data,
229240
_ => unreachable!(),
230241
};
231242

232243
let file = std::fs::File::open("/tmp/ca.key").unwrap();
233244
let mut reader = std::io::BufReader::new(file);
234-
let private_key = match rustls_pemfile::read_one(&mut reader).unwrap().unwrap() {
235-
rustls_pemfile::Item::Pkcs8Key(key) => rustls::pki_types::PrivateKeyDer::Pkcs8(key),
236-
_ => unreachable!(),
237-
};
245+
let private_key = PrivateKeyDer::from_pem_reader(&mut reader).unwrap();
238246

239247
let config = rustls::ClientConfig::builder()
240248
.with_root_certificates(root_store)
241-
.with_client_auth_cert(vec![producer_root], private_key)
249+
.with_client_auth_cert(vec![producer_root.into()], private_key)
242250
.unwrap();
243251

244252
let test_cfg = maybe_skip_kafka_integration!();

0 commit comments

Comments
 (0)