Skip to content

Commit 84aca0b

Browse files
committed
piv-ca: add expiry/notafter time to log entries
1 parent d745a00 commit 84aca0b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

piv-ca.c

+13
Original file line numberDiff line numberDiff line change
@@ -4236,6 +4236,9 @@ ca_log_cert_action(struct ca *ca, struct ca_session *sess, const char *action,
42364236
ASN1_INTEGER *serialasn1;
42374237
BIGNUM *serial = NULL;
42384238
char *serialhex = NULL;
4239+
const ASN1_TIME *asn1time;
4240+
struct tm tmv;
4241+
time_t t;
42394242

42404243
err = ca_log_verify(ca, &prev_hash, NULL, NULL);
42414244
if (err != ERRF_OK) {
@@ -4314,6 +4317,16 @@ ca_log_cert_action(struct ca *ca, struct ca_session *sess, const char *action,
43144317
json_object_object_add(robj, "serial", obj);
43154318
obj = NULL;
43164319

4320+
bzero(&tmv, sizeof (tmv));
4321+
asn1time = X509_get0_notAfter(cert);
4322+
if (asn1time && ASN1_TIME_to_tm(asn1time, &tmv) == 1) {
4323+
t = timegm(&tmv);
4324+
obj = json_object_new_int64(t);
4325+
VERIFY(obj != NULL);
4326+
json_object_object_add(robj, "expiry", obj);
4327+
obj = NULL;
4328+
}
4329+
43174330
err = ca_sign_json(ca, sess, robj);
43184331
if (err != ERRF_OK) {
43194332
err = errf("CALogError", err, "Failed to sign CA "

0 commit comments

Comments
 (0)