1
0
mirror of https://github.com/pcvolkmer/cert-tools.git synced 2025-07-01 14:02:54 +00:00

feat: show if file is invalid

This commit is contained in:
2025-01-06 18:29:48 +01:00
parent 7905603aad
commit c02474ac37
3 changed files with 216 additions and 209 deletions

View File

@ -57,7 +57,7 @@ pub enum StringValue {
impl Display for StringValue {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
StringValue::Valid(val) => write!(f, "{}", val),
StringValue::Valid(val) => write!(f, "{val}"),
StringValue::Invalid => write!(f, "*Invalid*"),
StringValue::Empty => write!(f, "*Empty*"),
}
@ -271,6 +271,10 @@ impl Chain {
return Err("Certificate chain contains invalid certificate".to_string());
}
if certs.is_empty() {
return Err("No Certificates found".to_string());
}
Ok(Self {
certs: certs.into_iter().flatten().collect::<Vec<_>>(),
})

View File

@ -72,7 +72,7 @@ fn main() -> Result<(), ()> {
match PrivateKey::read(Path::new(&key)) {
Ok(private_key) => {
if let Some(cert) = chain.certs().first() {
if cert.public_key_matches(private_key) {
if cert.public_key_matches(&private_key) {
println!(
"{}",
style("✓ Private Key matches first Cert Public Key")