diff --git a/Cargo.lock b/Cargo.lock index a96b782..ebddcaf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -336,7 +336,7 @@ dependencies = [ [[package]] name = "card-cli" -version = "1.5.0" +version = "1.5.1" dependencies = [ "authenticator", "base64 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 03e9422..48a6760 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "card-cli" -version = "1.5.0" +version = "1.5.1" authors = ["Hatter Jiang "] edition = "2018" diff --git a/src/cmd_pivmeta.rs b/src/cmd_pivmeta.rs index b494b3f..c050057 100644 --- a/src/cmd_pivmeta.rs +++ b/src/cmd_pivmeta.rs @@ -7,6 +7,7 @@ use rust_util::util_clap::{Command, CommandError}; use rust_util::util_msg; use rust_util::util_msg::MessageType; use x509::SubjectPublicKeyInfo; +use x509_parser::parse_x509_certificate; use yubikey::{Key, PinPolicy, TouchPolicy, YubiKey}; use yubikey::certificate::PublicKeyInfo; use yubikey::piv::{AlgorithmId, ManagementAlgorithmId, metadata, Origin, RetiredSlotId, SlotId}; @@ -133,9 +134,14 @@ impl Command for CommandImpl { json.insert("serial", k.certificate().serial().to_string()); json.insert("certificate_hex", k.certificate().encode_hex::()); + let x509_certificate = parse_x509_certificate(k.certificate().as_ref()).unwrap().1; + let public_key_bytes = x509_certificate.public_key().raw; + json.insert("public_key_hex", hex::encode(public_key_bytes)); + if !json_output { information!("Subject: {}", k.certificate().subject()); information!("Certificate: {}", bytes_to_pem("CERTIFICATE", k.certificate().as_ref())); + information!("Public key: {}", bytes_to_pem("PUBLIC KEY", public_key_bytes)); } } else { util_msg::when(MessageType::DEBUG, || {