summaryrefslogtreecommitdiff
path: root/usr.sbin/rpki-client
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2024-06-08 13:30:36 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2024-06-08 13:30:36 +0000
commit2474256db6c5b3ef3f42698511a2c94b167aaac1 (patch)
tree06c64cc0f769d0ff40f1714b6b4871bbc9175649 /usr.sbin/rpki-client
parentc1a95469893cc0c38a9379bad08f37e756a9a55d (diff)
Helper to convert purpose into a printable string
ok job
Diffstat (limited to 'usr.sbin/rpki-client')
-rw-r--r--usr.sbin/rpki-client/extern.h3
-rw-r--r--usr.sbin/rpki-client/print.c21
2 files changed, 22 insertions, 2 deletions
diff --git a/usr.sbin/rpki-client/extern.h b/usr.sbin/rpki-client/extern.h
index 7b431a7d8d2..b811b485e3e 100644
--- a/usr.sbin/rpki-client/extern.h
+++ b/usr.sbin/rpki-client/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.223 2024/06/08 13:29:54 tb Exp $ */
+/* $OpenBSD: extern.h,v 1.224 2024/06/08 13:30:35 tb Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -925,6 +925,7 @@ time_t x509_find_expires(time_t, struct auth *, struct crl_tree *);
/* printers */
char *nid2str(int);
+const char *purpose2str(enum cert_purpose);
char *time2str(time_t);
void x509_print(const X509 *);
void tal_print(const struct tal *);
diff --git a/usr.sbin/rpki-client/print.c b/usr.sbin/rpki-client/print.c
index 3fbf3553769..6738cbc7a43 100644
--- a/usr.sbin/rpki-client/print.c
+++ b/usr.sbin/rpki-client/print.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print.c,v 1.54 2024/06/06 05:57:36 tb Exp $ */
+/* $OpenBSD: print.c,v 1.55 2024/06/08 13:30:35 tb Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -65,6 +65,25 @@ nid2str(int nid)
return buf;
}
+const char *
+purpose2str(enum cert_purpose purpose)
+{
+ switch (purpose) {
+ case CERT_PURPOSE_INVALID:
+ return "invalid cert";
+ case CERT_PURPOSE_TA:
+ return "TA cert";
+ case CERT_PURPOSE_CA:
+ return "CA cert";
+ case CERT_PURPOSE_EE:
+ return "EE cert";
+ case CERT_PURPOSE_BGPSEC_ROUTER:
+ return "BGPsec Router cert";
+ default:
+ return "unknown certificate purpose";
+ }
+}
+
char *
time2str(time_t t)
{