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

27
Cargo.lock generated
View File

@@ -70,9 +70,9 @@ dependencies = [
[[package]]
name = "asn1-rs"
version = "0.3.1"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30ff05a702273012438132f449575dbc804e27b2f3cbe3069aa237d26c98fa33"
checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0"
dependencies = [
"asn1-rs-derive",
"asn1-rs-impl",
@@ -86,9 +86,9 @@ dependencies = [
[[package]]
name = "asn1-rs-derive"
version = "0.1.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf"
checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c"
dependencies = [
"proc-macro2",
"quote 1.0.33",
@@ -153,12 +153,6 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
[[package]]
name = "base64"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
name = "base64"
version = "0.21.2"
@@ -615,9 +609,9 @@ dependencies = [
[[package]]
name = "der-parser"
version = "7.0.0"
version = "8.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe398ac75057914d7d07307bf67dc7f3f574a26783b4fc7805a20ffa9f506e82"
checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e"
dependencies = [
"asn1-rs",
"displaydoc",
@@ -1454,9 +1448,9 @@ dependencies = [
[[package]]
name = "oid-registry"
version = "0.4.0"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38e20717fa0541f39bd146692035c37bedfa532b3e5071b35761082407546b2a"
checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff"
dependencies = [
"asn1-rs",
]
@@ -3065,12 +3059,11 @@ dependencies = [
[[package]]
name = "x509-parser"
version = "0.13.2"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fb9bace5b5589ffead1afb76e43e34cff39cd0f3ce7e170ae0c29e53b88eb1c"
checksum = "7069fba5b66b9193bd2c5d3d4ff12b839118f6bcbef5328efafafb5395cf63da"
dependencies = [
"asn1-rs",
"base64 0.13.1",
"data-encoding",
"der-parser",
"lazy_static",

View File

@@ -29,7 +29,7 @@ pem = "3.0"
yubikey = { version = "0.8", features = ["untested"] }
yubico_manager = "0.9"
x509 = "0.2"
x509-parser = "0.13"
x509-parser = "0.15"
ssh-agent = { version = "0.2", features = ["agent"] }
p256 = { version = "0.13", features = ["pem", "ecdh"] }
spki = { version = "0.7", features = ["pem"] }

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),