1
0
mirror of https://github.com/pcvolkmer/cert-tools.git synced 2025-04-19 17:06:49 +00:00

chore: code cleanup

This commit is contained in:
Paul-Christian Volkmer 2025-01-14 19:55:07 +01:00
parent 8a6b5118a0
commit 6b5fefec71

View File

@ -42,14 +42,14 @@ fn main() -> Result<(), ()> {
chain.push(ca_cert); chain.push(ca_cert);
} }
} else { } else {
println!("{}", style(format!("Cannot read file: {}", ca)).red()); println!("{}", style(format!("Cannot read file: {ca}")).red());
return Err(()); return Err(());
} }
} }
for cert in chain.certs() { for cert in chain.certs() {
print_cert(cert); print_cert(cert);
println!() println!();
} }
if chain.has_missing_tail() { if chain.has_missing_tail() {
@ -77,19 +77,19 @@ fn main() -> Result<(), ()> {
"{}", "{}",
style("✓ Private Key matches first Cert Public Key") style("✓ Private Key matches first Cert Public Key")
.green() .green()
) );
} else { } else {
println!("{}", style("! Private Key does not match the first Cert Public Key").red()) println!("{}", style("! Private Key does not match the first Cert Public Key").red());
} }
} }
} }
_ => { _ => {
println!("{}", style("Could not read Private Key").red()) println!("{}", style("Could not read Private Key").red());
} }
} }
} }
} else { } else {
println!("{}", style(format!("Cannot read file: {}", cert)).red()); println!("{}", style(format!("Cannot read file: {cert}")).red());
return Err(()); return Err(());
} }
} }
@ -103,7 +103,7 @@ fn main() -> Result<(), ()> {
chain.push(ca_cert); chain.push(ca_cert);
} }
} else { } else {
eprintln!("{}", style(format!("Cannot read file: {}", ca)).red()); eprintln!("{}", style(format!("Cannot read file: {ca}")).red());
return Err(()); return Err(());
} }
} }
@ -131,19 +131,16 @@ fn main() -> Result<(), ()> {
return Err(()); return Err(());
} }
for cert in chain.certs() { for cert in chain.certs() {
match cert.to_pem() { if let Ok(plain) = cert.to_pem() { print!("{plain}") } else {
Ok(plain) => print!("{}", plain), eprintln!(
Err(_) => { "{}",
eprintln!( style("Cannot merge files to valid chain - Cert error!").red()
"{}", );
style("Cannot merge files to valid chain - Cert error!").red() return Err(());
);
return Err(());
}
} }
} }
} else { } else {
eprintln!("{}", style(format!("Cannot read file: {}", cert)).red()); eprintln!("{}", style(format!("Cannot read file: {cert}")).red());
return Err(()); return Err(());
} }
eprintln!("{}", style("Success!").green()); eprintln!("{}", style("Success!").green());