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