persistence: improving PEM file reading and parsing failure messages

This commit is contained in:
Dave Hrycyszyn
2020-01-09 10:48:36 +00:00
parent ac78e160df
commit fd9829bedd
@@ -35,10 +35,12 @@ impl PemStore {
}
fn read_file(&self, filepath: PathBuf) -> Vec<u8> {
let mut pem_bytes = File::open(filepath).unwrap();
let mut pem_bytes = File::open(filepath).expect("Could not open stored keys from disk.");
let mut buf = Vec::new();
pem_bytes.read_to_end(&mut buf).unwrap();
let pem = parse(&buf).unwrap();
pem_bytes
.read_to_end(&mut buf)
.expect("PEM bytes reading failed.");
let pem = parse(&buf).expect("PEM parsing failed while reading keys");
pem.contents
}
// This should be refactored and made more generic for when we have other kinds of