feat: v1.5.1, add piv public key outputs
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -336,7 +336,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "card-cli"
|
name = "card-cli"
|
||||||
version = "1.5.0"
|
version = "1.5.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"authenticator",
|
"authenticator",
|
||||||
"base64 0.13.1",
|
"base64 0.13.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "card-cli"
|
name = "card-cli"
|
||||||
version = "1.5.0"
|
version = "1.5.1"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use rust_util::util_clap::{Command, CommandError};
|
|||||||
use rust_util::util_msg;
|
use rust_util::util_msg;
|
||||||
use rust_util::util_msg::MessageType;
|
use rust_util::util_msg::MessageType;
|
||||||
use x509::SubjectPublicKeyInfo;
|
use x509::SubjectPublicKeyInfo;
|
||||||
|
use x509_parser::parse_x509_certificate;
|
||||||
use yubikey::{Key, PinPolicy, TouchPolicy, YubiKey};
|
use yubikey::{Key, PinPolicy, TouchPolicy, YubiKey};
|
||||||
use yubikey::certificate::PublicKeyInfo;
|
use yubikey::certificate::PublicKeyInfo;
|
||||||
use yubikey::piv::{AlgorithmId, ManagementAlgorithmId, metadata, Origin, RetiredSlotId, SlotId};
|
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("serial", k.certificate().serial().to_string());
|
||||||
json.insert("certificate_hex", k.certificate().encode_hex::<String>());
|
json.insert("certificate_hex", k.certificate().encode_hex::<String>());
|
||||||
|
|
||||||
|
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 {
|
if !json_output {
|
||||||
information!("Subject: {}", k.certificate().subject());
|
information!("Subject: {}", k.certificate().subject());
|
||||||
information!("Certificate: {}", bytes_to_pem("CERTIFICATE", k.certificate().as_ref()));
|
information!("Certificate: {}", bytes_to_pem("CERTIFICATE", k.certificate().as_ref()));
|
||||||
|
information!("Public key: {}", bytes_to_pem("PUBLIC KEY", public_key_bytes));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
util_msg::when(MessageType::DEBUG, || {
|
util_msg::when(MessageType::DEBUG, || {
|
||||||
|
|||||||
Reference in New Issue
Block a user