From 8c08b2605471a62d92ca70a0ec163a4349a9cbfe Mon Sep 17 00:00:00 2001 From: tb Date: Wed, 24 Nov 2021 19:24:46 +0000 Subject: [PATCH] Fix timestamp printing in Signed Certificate Timestamps Our ASN1_GENERALIZEDTIME_set() doesn't accept time strings with fractional seconds, so don't feed it milliseconds, but only seconds. Ensures that openssl x509 -text prints timestamps instead of skipping them. ok beck jsing --- lib/libcrypto/ct/ct_prn.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/libcrypto/ct/ct_prn.c b/lib/libcrypto/ct/ct_prn.c index 3b1be713946..37781ee37bd 100644 --- a/lib/libcrypto/ct/ct_prn.c +++ b/lib/libcrypto/ct/ct_prn.c @@ -71,8 +71,7 @@ timestamp_print(uint64_t timestamp, BIO *out) * Note GeneralizedTime from ASN1_GENERALIZETIME_adj is always 15 * characters long with a final Z. Update it with fractional seconds. */ - snprintf(genstr, sizeof(genstr), "%.14s.%03dZ", - ASN1_STRING_get0_data(gen), (unsigned int)(timestamp % 1000)); + snprintf(genstr, sizeof(genstr), "%.14sZ", ASN1_STRING_get0_data(gen)); if (ASN1_GENERALIZEDTIME_set_string(gen, genstr)) ASN1_GENERALIZEDTIME_print(out, gen); ASN1_GENERALIZEDTIME_free(gen); -- 2.20.1