]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
tls: update x509 crate to v0.8
authorPhilippe Antoine <pantoine@oisf.net>
Fri, 30 Jun 2023 07:00:49 +0000 (09:00 +0200)
committerVictor Julien <vjulien@oisf.net>
Mon, 10 Jul 2023 15:48:55 +0000 (17:48 +0200)
Ticket: #5439

Fixes cetificate parsing without issuer, and do not require an
update to MSRV.

rust/Cargo.toml.in
rust/src/x509/mod.rs

index 36daa9de87d48145c48fb30fe9690c079f8d8884..fda82e3487e78f354daaef82601a1d8c53494329 100644 (file)
@@ -41,7 +41,11 @@ ntp-parser = "0.4"
 ipsec-parser = "0.5"
 snmp-parser = "0.6"
 tls-parser = "0.9"
-x509-parser = "0.6.5"
+# required by x509 to keep MSRV support
+chrono = "=0.4.19"
+thiserror = "=1.0.39"
+data-encoding = "=2.3.3"
+x509-parser = "0.8.2"
 libc = "0.2.67"
 
 [dev-dependencies]
index 353edb1d44113f1fa20cd0518df9dc9f147246f6..5ab268ba5b201e69987050b053a03a2117a101c9 100644 (file)
@@ -30,12 +30,8 @@ pub enum X509DecodeError {
     InvalidCert,
     /// Some length does not match, or certificate is incomplete
     InvalidLength,
-    InvalidVersion,
-    InvalidSerial,
-    InvalidAlgorithmIdentifier,
     InvalidX509Name,
     InvalidDate,
-    InvalidExtensions,
     /// DER structure is invalid
     InvalidDER,
 }
@@ -112,8 +108,8 @@ pub unsafe extern "C" fn rs_x509_get_validity(
         return -1;
     }
     let x509 = &*ptr;
-    let n_b = x509.0.tbs_certificate.validity.not_before.to_timespec().sec;
-    let n_a = x509.0.tbs_certificate.validity.not_after.to_timespec().sec;
+    let n_b = x509.0.tbs_certificate.validity.not_before.timestamp();
+    let n_a = x509.0.tbs_certificate.validity.not_after.timestamp();
     *not_before = n_b;
     *not_after = n_a;
     0
@@ -136,12 +132,8 @@ fn x509_parse_error_to_errcode(e: &nom::Err<X509Error>) -> X509DecodeError {
     match e {
         nom::Err::Incomplete(_) => X509DecodeError::InvalidLength,
         nom::Err::Error(e) | nom::Err::Failure(e) => match e {
-            X509Error::InvalidVersion => X509DecodeError::InvalidVersion,
-            X509Error::InvalidSerial => X509DecodeError::InvalidSerial,
-            X509Error::InvalidAlgorithmIdentifier => X509DecodeError::InvalidAlgorithmIdentifier,
             X509Error::InvalidX509Name => X509DecodeError::InvalidX509Name,
             X509Error::InvalidDate => X509DecodeError::InvalidDate,
-            X509Error::InvalidExtensions => X509DecodeError::InvalidExtensions,
             X509Error::Der(_) => X509DecodeError::InvalidDER,
             _ => X509DecodeError::InvalidCert,
         },