use once_cell::sync::Lazy; use std::{fs, io::Read}; macro_rules! read { ($env:ident, $default:literal) => { pub static $env: Lazy = Lazy::new(|| { let path = option_env!("$env").unwrap_or($default); let mut f = fs::File::open(path).unwrap(); let mut s = String::new(); f.read_to_string(&mut s).unwrap(); s }); }; } read!(PUB_KEY_PEM, "public.pem"); read!(PRIV_KEY_PEM, "private.pem"); #[cfg(test)] mod tests { use openssl::pkey::PKey; use super::*; #[test] fn test_parse_pems() { let public = PKey::public_key_from_pem(PUB_KEY_PEM.as_ref()); assert!(public.is_ok()); let private = PKey::private_key_from_pem(PRIV_KEY_PEM.as_ref()); assert!(private.is_ok()); } }