From cb2fe0d1945a16239366e006ee66f24678813b72 Mon Sep 17 00:00:00 2001 From: Tim Bruijnzeels Date: Wed, 16 Oct 2019 12:43:23 +0200 Subject: [PATCH] Use latest time encoding. #3 --- src/commons/remote/builder.rs | 6 +++--- src/commons/remote/id.rs | 4 ++-- src/daemon/ca/certauth.rs | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/commons/remote/builder.rs b/src/commons/remote/builder.rs index a35732ec..f089d4e6 100644 --- a/src/commons/remote/builder.rs +++ b/src/commons/remote/builder.rs @@ -357,7 +357,7 @@ impl SignedAttributes { // attribute using the time that the SignedAttributes // was created. oid::SIGNING_TIME.encode(), - encode::set(self.signing_time.encode()), + encode::set(self.signing_time.encode_varied()), )), encode::sequence(( oid::MESSAGE_DIGEST.encode(), @@ -492,8 +492,8 @@ impl SigMsgCrlBuilder { name.encode_ref(), ), ( - just_now.encode(), - in_a_bit.encode(), + just_now.encode_varied(), + in_a_bit.encode_varied(), // Real revocations go here extensions, ), diff --git a/src/commons/remote/id.rs b/src/commons/remote/id.rs index 4f365555..5ff64681 100644 --- a/src/commons/remote/id.rs +++ b/src/commons/remote/id.rs @@ -342,7 +342,7 @@ impl IdCert { // Validity. Check according to RFC 5280. self.validity.validate_at(now)?; - // Subject Key Identifer. Must be the SHA-1 hash of the octets + // Subject Key Identifier. Must be the SHA-1 hash of the octets // of the subjectPublicKey. if self.extensions.subject_key_id().as_slice().unwrap() != self.subject_public_key_info().key_identifier().as_ref() @@ -574,7 +574,7 @@ pub mod tests { } #[test] - fn should_parse_id_publisher_ta_cert() { + fn parse_id_publisher_ta_cert() { test_id_certificate() .validate_ta_at(Time::utc(2012, 1, 1, 0, 0, 0)) .unwrap(); diff --git a/src/daemon/ca/certauth.rs b/src/daemon/ca/certauth.rs index a08f6461..3aae38cb 100644 --- a/src/daemon/ca/certauth.rs +++ b/src/daemon/ca/certauth.rs @@ -1378,3 +1378,21 @@ impl CertAuth { Ok(res) } } + +//------------ Tests --------------------------------------------------------- + +#[cfg(test)] +mod tests { + use super::*; + use crate::commons::util::softsigner::OpenSslSigner; + use crate::commons::util::test; + + #[test] + fn generate_id_cert() { + test::test_under_tmp(|d| { + let mut signer = OpenSslSigner::build(&d).unwrap(); + let id = Rfc8183Id::generate(&mut signer).unwrap(); + id.cert.validate_ta().unwrap(); + }); + } +}