Skip to content

Commit 229fd45

Browse files
committed
Use path from match
1 parent c3d8b8b commit 229fd45

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

rust/cert-tools/src/cli_args.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,28 @@ impl GeneratePkcs12 {
8080

8181
impl CertInput {
8282
pub fn read(&self) -> Result<Vec<X509>, snafu::Whatever> {
83-
let file_contents = fs::read(self.path())
84-
.with_whatever_context(|_| format!("failed to read file from {self:?}"))?;
85-
8683
match self {
87-
CertInput::Pem(_) => {
84+
CertInput::Pem(path) => {
85+
let file_contents = fs::read(path)
86+
.with_whatever_context(|_| format!("failed to read file from {self:?}"))?;
87+
8888
let certs = parse_pem_contents(&file_contents).with_whatever_context(|_| {
8989
format!(
9090
"failed to parse PEM contents from {path:?}",
9191
path = self.path()
9292
)
9393
})?;
94-
let path = self.path();
9594
ensure_whatever!(
9695
!certs.is_empty(),
9796
"The PEM file at {path:?} contained no certificates",
9897
);
9998

10099
Ok(certs)
101100
}
102-
CertInput::Pkcs12(Pkcs12Source { password, .. }) => {
101+
CertInput::Pkcs12(Pkcs12Source { path, password }) => {
102+
let file_contents = fs::read(path)
103+
.with_whatever_context(|_| format!("failed to read file from {self:?}"))?;
104+
103105
parse_pkcs12_file_workaround(&file_contents, password)
104106
}
105107
}

0 commit comments

Comments
 (0)