use mktemp::Temp; use crate::test::test_files_utils::create_temp_file_with_content; pub struct PemHolder(Temp); impl PemHolder { fn new(b: &[u8]) -> Self { Self(create_temp_file_with_content(b)) } pub fn file_path(&self) -> String { self.0.to_str().unwrap().to_string() } } pub struct Pki { pub expired_client_key: PemHolder, pub expired_client_crt: PemHolder, pub localhost_crt: PemHolder, pub localhost_key: PemHolder, pub other_ca_crl: PemHolder, pub other_ca_crt: PemHolder, pub other_ca_key: PemHolder, pub revoked_client_crt: PemHolder, pub revoked_client_key: PemHolder, pub root_ca_crl: PemHolder, pub root_ca_crt: PemHolder, pub root_ca_key: PemHolder, pub valid_client_crt: PemHolder, pub valid_client_key: PemHolder, } impl Pki { pub fn load() -> Self { Self { expired_client_key: PemHolder::new(include_bytes!("test_pki/ExpiredClient.key")), expired_client_crt: PemHolder::new(include_bytes!("test_pki/ExpiredClient.crt")), localhost_crt: PemHolder::new(include_bytes!("test_pki/localhost.crt")), localhost_key: PemHolder::new(include_bytes!("test_pki/localhost.key")), other_ca_crl: PemHolder::new(include_bytes!("test_pki/OtherCA.crl")), other_ca_crt: PemHolder::new(include_bytes!("test_pki/OtherCA.crt")), other_ca_key: PemHolder::new(include_bytes!("test_pki/OtherCA.key")), revoked_client_crt: PemHolder::new(include_bytes!("test_pki/RevokedClient.crt")), revoked_client_key: PemHolder::new(include_bytes!("test_pki/RevokedClient.key")), root_ca_crl: PemHolder::new(include_bytes!("test_pki/TCPTunnelTestCA.crl")), root_ca_crt: PemHolder::new(include_bytes!("test_pki/TCPTunnelTestCA.crt")), root_ca_key: PemHolder::new(include_bytes!("test_pki/TCPTunnelTestCA.key")), valid_client_crt: PemHolder::new(include_bytes!("test_pki/ValidClient.crt")), valid_client_key: PemHolder::new(include_bytes!("test_pki/ValidClient.key")), } } }