feat: update x509-parser version

This commit is contained in:
2023-08-26 12:25:04 +08:00
parent 1698e2d9f8
commit ffd0e6233f
4 changed files with 19 additions and 23 deletions

View File

@@ -113,7 +113,7 @@ fn print_cert_info(yubikey: &mut YubiKey, slot: SlotId, detail_output: bool) ->
information!("Issuer: {}", cert.tbs_certificate.issuer);
information!("Certificate fingerprint(SHA256): {}", hex::encode(certificate_fingerprint_sha256));
information!("Public key fingerprint(SHA256): {}", hex::encode(public_key_fingerprint_sha256));
information!("Not Before: {}", cert.tbs_certificate.validity.not_before.to_rfc2822());
information!("Not Before: {}", cert.tbs_certificate.validity.not_before.to_rfc2822().unwrap_or_else(|e| format!("Err: {}", e)));
let mut not_after_desc = String::new();
let not_after_timestamp = cert.tbs_certificate.validity.not_after.timestamp();
@@ -125,7 +125,10 @@ fn print_cert_info(yubikey: &mut YubiKey, slot: SlotId, detail_output: bool) ->
let valid_time = simpledateformat::format_human(Duration::from_secs((not_after_timestamp - now_timestamp) as u64));
not_after_desc.push_str(&format!("(left {})", valid_time));
}
information!("Not After: {} {}", cert.tbs_certificate.validity.not_after.to_rfc2822(), not_after_desc);
information!("Not After: {} {}",
cert.tbs_certificate.validity.not_after.to_rfc2822().unwrap_or_else(|e| format!("Err: {}", e)),
not_after_desc
);
}
_ => {
warning!("Failed to parse certificate");

View File

@@ -23,9 +23,9 @@ pub fn get_pki_algorithm(algorithm_identifier: &AlgorithmIdentifier) -> XResult<
}
if "1.2.840.10045.2.1" == algorithm_id_string {
if let Some(parameters) = &algorithm_identifier.parameters {
if let Ok(content) = parameters.content.as_oid() {
let content_id_string = content.to_id_string();
return match content_id_string.as_str() {
if let Ok(parameter_oid) = parameters.as_oid() {
let parameter_oid_id_string = parameter_oid.to_id_string();
return match parameter_oid_id_string.as_str() {
"1.2.840.10045.3.1.7" => Ok(PkiAlgorithm::P256),
"1.3.132.0.34" => Ok(PkiAlgorithm::P384),
"1.3.132.0.35" => Ok(PkiAlgorithm::P521),