From: Pierre Chifflier Date: Mon, 9 Mar 2020 19:36:21 +0000 (+0100) Subject: rust/x509: use the raw serial number so leading zeros are not removed X-Git-Tag: suricata-6.0.0-beta1~600 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36d2e257c6b00f816443ac53ba7f8f015b06e3ee;p=thirdparty%2Fsuricata.git rust/x509: use the raw serial number so leading zeros are not removed --- diff --git a/rust/Cargo.toml.in b/rust/Cargo.toml.in index 05bea9cffe..b85d8f53c2 100644 --- a/rust/Cargo.toml.in +++ b/rust/Cargo.toml.in @@ -34,4 +34,4 @@ ntp-parser = "0.4" ipsec-parser = "0.5" snmp-parser = "0.5" tls-parser = "0.9" -x509-parser = "0.6" +x509-parser = "0.6.5" diff --git a/rust/src/x509/mod.rs b/rust/src/x509/mod.rs index 780dc6291f..f003b2a292 100644 --- a/rust/src/x509/mod.rs +++ b/rust/src/x509/mod.rs @@ -65,7 +65,12 @@ pub extern "C" fn rs_x509_get_serial(ptr: *const X509) -> *mut c_char { return std::ptr::null_mut(); } let x509 = cast_pointer! {ptr, X509}; - let serial = x509.0.tbs_certificate.serial.to_string(); + let raw_serial = x509.0.tbs_certificate.raw_serial(); + let v : Vec<_> = raw_serial + .iter() + .map(|x| format!("{:02X}", x)) + .collect(); + let serial = v.join(":"); rust_string_to_c(serial) }