From 28439bbc17f565f474c6e38f91da59393a4514bb Mon Sep 17 00:00:00 2001 From: job Date: Wed, 14 Dec 2022 08:46:58 +0000 Subject: [PATCH] Print expiry moment in human-readable filemode in a consistent fashion across all object types OK claudio@ tb@ --- usr.sbin/rpki-client/print.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/usr.sbin/rpki-client/print.c b/usr.sbin/rpki-client/print.c index 95639dccd10..6a9def1a6c3 100644 --- a/usr.sbin/rpki-client/print.c +++ b/usr.sbin/rpki-client/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.23 2022/12/14 02:34:32 job Exp $ */ +/* $OpenBSD: print.c,v 1.24 2022/12/14 08:46:58 job Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -158,9 +158,6 @@ cert_print(const struct cert *p) size_t i, j; char buf1[64], buf2[64]; int sockt; - char tbuf[21]; - - strftime(tbuf, sizeof(tbuf), "%FT%TZ", gmtime(&p->expires)); if (outformats & FORMAT_JSON) { if (p->pubkey != NULL) @@ -200,9 +197,11 @@ cert_print(const struct cert *p) if (p->pubkey != NULL) { printf("BGPsec ECDSA public key: %s\n", p->pubkey); - printf("Router key valid until: %s\n", tbuf); + printf("Router key valid until: %s\n", + time2str(p->expires)); } else - printf("Certificate valid until: %s\n", tbuf); + printf("Certificate valid until: %s\n", + time2str(p->expires)); printf("Subordinate resources:\n"); } @@ -484,13 +483,11 @@ gbr_print(const X509 *x, const struct gbr *p) void rsc_print(const X509 *x, const struct rsc *p) { - char buf1[64], buf2[64], tbuf[21]; + char buf1[64], buf2[64]; char *hash; int sockt; size_t i, j; - strftime(tbuf, sizeof(tbuf), "%FT%TZ", gmtime(&p->expires)); - if (outformats & FORMAT_JSON) { printf("\t\"ski\": \"%s\",\n", pretty_key_id(p->ski)); printf("\t\"aki\": \"%s\",\n", pretty_key_id(p->aki)); @@ -503,7 +500,7 @@ rsc_print(const X509 *x, const struct rsc *p) printf("Authority key identifier: %s\n", pretty_key_id(p->aki)); x509_print(x); printf("Authority info access: %s\n", p->aia); - printf("Valid until: %s\n", tbuf); + printf("RSC valid until: %s\n", time2str(p->expires)); printf("Signed with resources:\n"); } @@ -609,6 +606,7 @@ aspa_print(const X509 *x, const struct aspa *p) printf("\t\"aki\": \"%s\",\n", pretty_key_id(p->aki)); printf("\t\"aia\": \"%s\",\n", p->aia); printf("\t\"sia\": \"%s\",\n", p->sia); + printf("\t\"valid_until\": %lld,\n", (long long)p->expires); printf("\t\"customer_asid\": %u,\n", p->custasid); printf("\t\"provider_set\": [\n"); for (i = 0; i < p->providersz; i++) { @@ -629,6 +627,7 @@ aspa_print(const X509 *x, const struct aspa *p) printf("Authority key identifier: %s\n", pretty_key_id(p->aki)); printf("Authority info access: %s\n", p->aia); printf("Subject info access: %s\n", p->sia); + printf("ASPA valid until: %s\n", time2str(p->expires)); printf("Customer AS: %u\n", p->custasid); printf("Provider Set:\n"); for (i = 0; i < p->providersz; i++) { @@ -703,8 +702,6 @@ takey_print(char *name, const struct takey *t) void tak_print(const X509 *x, const struct tak *p) { - char tbuf[21]; - if (outformats & FORMAT_JSON) { printf("\t\"type\": \"tak\",\n"); printf("\t\"ski\": \"%s\",\n", pretty_key_id(p->ski)); @@ -715,13 +712,12 @@ tak_print(const X509 *x, const struct tak *p) printf("\t\"valid_until\": %lld,\n", (long long)p->expires); printf("\t\"takeys\": [\n"); } else { - strftime(tbuf, sizeof(tbuf), "%FT%TZ", gmtime(&p->expires)); printf("Subject key identifier: %s\n", pretty_key_id(p->ski)); x509_print(x); printf("Authority key identifier: %s\n", pretty_key_id(p->aki)); printf("Authority info access: %s\n", p->aia); printf("Subject info access: %s\n", p->sia); - printf("TAK valid until: %s\n", tbuf); + printf("TAK valid until: %s\n", time2str(p->expires)); } takey_print("current", p->current); -- 2.20.1