Fix timestamp printing in Signed Certificate Timestamps
authortb <tb@openbsd.org>
Wed, 24 Nov 2021 19:24:46 +0000 (19:24 +0000)
committertb <tb@openbsd.org>
Wed, 24 Nov 2021 19:24:46 +0000 (19:24 +0000)
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

index 3b1be71..37781ee 100644 (file)
@@ -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);