From 8984fc5678ee7b9cac8dc9fd240b512ac26874b5 Mon Sep 17 00:00:00 2001 From: Mathieu Amiot Date: Mon, 19 Feb 2024 18:39:33 +0100 Subject: [PATCH] fix: Harden x509 validation & revocation checks --- crypto/src/e2e_identity/init_certificates.rs | 14 +++++--------- crypto/src/test_utils/x509.rs | 6 +++--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/crypto/src/e2e_identity/init_certificates.rs b/crypto/src/e2e_identity/init_certificates.rs index ab3b97353c..df4962748f 100644 --- a/crypto/src/e2e_identity/init_certificates.rs +++ b/crypto/src/e2e_identity/init_certificates.rs @@ -135,20 +135,17 @@ impl MlsCentral { /// # Returns /// A [CrlRegistration] with the dirty state of the new CRL (see struct) and its expiration timestamp pub async fn e2ei_register_crl(&self, crl_dp: String, crl_der: Vec) -> CryptoResult { - // Parse/decode DER CRL - let crl = PkiEnvironment::decode_der_crl(crl_der).map_err(|e| CryptoError::E2eiError(e.into()))?; - - // Validate CRL - { + // Parse & Validate CRL + let crl = { let auth_service_arc = self.mls_backend.authentication_service().clone(); let auth_service = auth_service_arc.borrow()?; let Some(pki_env) = auth_service.as_ref() else { return Err(CryptoError::ConsumerError); }; pki_env - .validate_crl(&crl) - .map_err(|e| CryptoError::E2eiError(e.into()))?; - } + .validate_crl_with_raw(&crl_der) + .map_err(|e| CryptoError::E2eiError(e.into()))? + }; let expiration = extract_expiration_from_crl(&crl); @@ -241,7 +238,6 @@ pub mod tests { if case.is_x509() { run_test_with_client_ids(case.clone(), ["alice"], move |[alice_central]| { Box::pin(async move { - let id = conversation_id(); let alice_test_chain = alice_central.x509_test_chain.as_ref().as_ref().unwrap(); let alice_ta = alice_test_chain .trust_anchor diff --git a/crypto/src/test_utils/x509.rs b/crypto/src/test_utils/x509.rs index 437c55bbbc..693e403415 100644 --- a/crypto/src/test_utils/x509.rs +++ b/crypto/src/test_utils/x509.rs @@ -240,11 +240,11 @@ impl X509TestChain { }) .collect(); - let local_crl_dp = local_intermediate.crl_dps.first().unwrap().clone(); + let local_crl_dp = trust_anchor.crl_dps.first().unwrap().clone(); - let crl = local_intermediate + let crl = trust_anchor .pki_keypair - .revoke_certs(&local_intermediate.certificate, revoked_serial_numbers) + .revoke_certs(&trust_anchor.certificate, revoked_serial_numbers) .unwrap(); crls.insert(local_crl_dp, crl);