rust/x509: update dependency on x509-parser

pull/7948/head
Pierre Chifflier 3 years ago committed by Victor Julien
parent b06c0579f5
commit 3aace49649

@ -47,7 +47,7 @@ ntp-parser = "~0.6.0"
ipsec-parser = "~0.7.0"
snmp-parser = "~0.6.0"
tls-parser = "~0.11.0"
x509-parser = "~0.6.5"
x509-parser = "~0.12.0"
libc = "~0.2.82"
sha2 = "~0.10.2"
digest = "~0.10.3"

@ -21,7 +21,7 @@ use super::rdp::{RdpTransaction, RdpTransactionItem};
use crate::jsonbuilder::{JsonBuilder, JsonError};
use crate::rdp::parser::*;
use crate::rdp::windows;
use x509_parser::parse_x509_der;
use x509_parser::prelude::{X509Certificate, FromDer};
#[no_mangle]
pub extern "C" fn rs_rdp_to_json(tx: &mut RdpTransaction, js: &mut JsonBuilder) -> bool {
@ -50,7 +50,7 @@ fn log(tx: &RdpTransaction, js: &mut JsonBuilder) -> Result<(), JsonError> {
js.set_string("event_type", "tls_handshake")?;
js.open_array("x509_serials")?;
for blob in chain {
match parse_x509_der(&blob.data) {
match X509Certificate::from_der(&blob.data) {
Ok((_, cert)) => {
js.append_string(&cert.tbs_certificate.serial.to_str_radix(16))?;
}

@ -18,10 +18,9 @@
// written by Pierre Chifflier <chifflier@wzdftpd.net>
use crate::common::rust_string_to_c;
use nom;
use std;
use std::os::raw::c_char;
use x509_parser::{error::X509Error, parse_x509_der, X509Certificate};
use x509_parser::prelude::*;
#[repr(u32)]
pub enum X509DecodeError {
@ -54,7 +53,7 @@ pub unsafe extern "C" fn rs_x509_decode(
err_code: *mut u32,
) -> *mut X509 {
let slice = std::slice::from_raw_parts(input, input_len as usize);
let res = parse_x509_der(slice);
let res = X509Certificate::from_der(slice);
match res {
Ok((_rem, cert)) => Box::into_raw(Box::new(X509(cert))),
Err(e) => {
@ -112,8 +111,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.validity().not_before.timestamp();
let n_a = x509.0.validity().not_after.timestamp();
*not_before = n_b;
*not_after = n_a;
0

Loading…
Cancel
Save