From d1b5f80fe556df650b7e9f1e4d3acc11fd7bf22b Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Tue, 22 Oct 2024 07:39:34 +0000 Subject: [PATCH] rust/utils: Use `PathBuf` for CertificateOptions It's more common to use a `PathBuf` for paths than a `String`. Signed-off-by: Marc Hartmayer Reviewed-by: Steffen Eiden Signed-off-by: Steffen Eiden --- rust/utils/src/cli.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/rust/utils/src/cli.rs b/rust/utils/src/cli.rs index 970f9f66..77260d33 100644 --- a/rust/utils/src/cli.rs +++ b/rust/utils/src/cli.rs @@ -14,7 +14,7 @@ use pv::{ Error, Result, }; use std::io::{Read, Write}; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::process::ExitCode; /// CLI Argument collection for handling host-keys, IBM signing keys, and certificates. @@ -35,7 +35,7 @@ pub struct CertificateOptions { use_value_delimiter = true, value_delimiter = ',', )] - pub host_key_documents: Vec, + pub host_key_documents: Vec, /// Disable the host-key document verification. /// @@ -58,7 +58,7 @@ pub struct CertificateOptions { use_value_delimiter = true, value_delimiter = ',', )] - pub certs: Vec, + pub certs: Vec, /// Use FILE as a certificate revocation list. /// @@ -72,7 +72,7 @@ pub struct CertificateOptions { use_value_delimiter = true, value_delimiter = ',', )] - pub crls: Vec, + pub crls: Vec, /// Make no attempt to download CRLs. #[arg(long, requires("certs"))] @@ -83,7 +83,7 @@ pub struct CertificateOptions { /// If omitted, the system wide-root CAs installed on the system are used. /// Use this only if you trust the specified certificate. #[arg(long, requires("certs"))] - pub root_ca: Option, + pub root_ca: Option, } impl CertificateOptions { @@ -128,21 +128,24 @@ impl CertificateOptions { for hkd in hkds { let hk = read_file(hkd, "host-key document")?; let certs = read_certs(&hk).map_err(|source| Error::HkdNotPemOrDer { - hkd: hkd.to_string(), + hkd: hkd.display().to_string(), source, })?; if certs.is_empty() { - return Err(Error::NoHkdInFile(hkd.to_string())); + return Err(Error::NoHkdInFile(hkd.display().to_string())); } if certs.len() != 1 { - warn!("The host-key document in '{hkd}' contains more than one certificate!") + warn!( + "The host-key document in '{}' contains more than one certificate!", + hkd.display() + ) } // Panic: len is == 1 -> unwrap will succeed/not panic let c = certs.first().unwrap(); verifier.verify(c)?; res.push(c.public_key()?); - info!("Use host-key document at '{hkd}'"); + info!("Use host-key document at '{}'", hkd.display()); } Ok(res) }