diff options
author | Joe Birr-Pixton <jpixton@gmail.com> | 2024-09-30 12:14:52 +0100 |
---|---|---|
committer | Joe Birr-Pixton <jpixton@gmail.com> | 2024-10-01 17:09:38 +0000 |
commit | 5a04f5e4b491129550196cd8bc1b8119c646e661 (patch) | |
tree | 6cc71803993eeffbaa83b748e0301be460231ec3 | |
parent | 7eff54be35ba3047d65ee6e247b117fdb3ebb04e (diff) |
openssl-tests: use pki-types pem decoder
-rw-r--r-- | Cargo.lock | 1 | ||||
-rw-r--r-- | openssl-tests/Cargo.toml | 3 | ||||
-rw-r--r-- | openssl-tests/src/ffdhe_kx_with_openssl.rs | 23 |
3 files changed, 7 insertions, 20 deletions
@@ -2197,7 +2197,6 @@ dependencies = [ "once_cell", "openssl", "rustls 0.23.13", - "rustls-pemfile", "rustls-pki-types", ] diff --git a/openssl-tests/Cargo.toml b/openssl-tests/Cargo.toml index f124885c..4fdfc318 100644 --- a/openssl-tests/Cargo.toml +++ b/openssl-tests/Cargo.toml @@ -12,6 +12,5 @@ base64 = "0.22" num-bigint = "0.4.4" once_cell = "1.19" rustls = {path = "../rustls"} -rustls-pemfile = "2" -rustls-pki-types = "1.0" +rustls-pki-types = "1.9" openssl = "0.10" diff --git a/openssl-tests/src/ffdhe_kx_with_openssl.rs b/openssl-tests/src/ffdhe_kx_with_openssl.rs index 89b814ee..a54183a1 100644 --- a/openssl-tests/src/ffdhe_kx_with_openssl.rs +++ b/openssl-tests/src/ffdhe_kx_with_openssl.rs @@ -1,14 +1,13 @@ -use std::fs::{self, File}; -use std::io::{BufReader, Read, Write}; +use std::io::{Read, Write}; use std::net::{TcpListener, TcpStream}; use std::sync::Arc; -use std::{str, thread}; +use std::{fs, str, thread}; use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; use rustls::crypto::{aws_lc_rs as provider, CryptoProvider}; use rustls::version::{TLS12, TLS13}; use rustls::{ClientConfig, RootCertStore, ServerConfig, SupportedProtocolVersion}; -use rustls_pemfile::Item; +use rustls_pki_types::pem::PemObject; use rustls_pki_types::{CertificateDer, PrivateKeyDer}; use crate::ffdhe::{self, FfdheKxGroup}; @@ -185,24 +184,14 @@ fn root_ca() -> RootCertStore { } fn load_certs() -> Vec<CertificateDer<'static>> { - let mut reader = BufReader::new(File::open(CERT_CHAIN_FILE).unwrap()); - rustls_pemfile::certs(&mut reader) + CertificateDer::pem_file_iter(CERT_CHAIN_FILE) + .unwrap() .map(|c| c.unwrap()) .collect() } fn load_private_key() -> PrivateKeyDer<'static> { - let mut reader = BufReader::new(File::open(PRIV_KEY_FILE).unwrap()); - - match rustls_pemfile::read_one(&mut reader) - .unwrap() - .unwrap() - { - Item::Pkcs1Key(key) => key.into(), - Item::Pkcs8Key(key) => key.into(), - Item::Sec1Key(key) => key.into(), - _ => panic!("no key in key file {PRIV_KEY_FILE}"), - } + PrivateKeyDer::from_pem_file(PRIV_KEY_FILE).unwrap() } fn ffdhe_provider() -> CryptoProvider { |