summaryrefslogtreecommitdiff
path: root/usr.sbin/rpki-client
diff options
context:
space:
mode:
authorJob Snijders <job@cvs.openbsd.org>2022-11-03 10:39:20 +0000
committerJob Snijders <job@cvs.openbsd.org>2022-11-03 10:39:20 +0000
commit8a5f1b3a2544095dd8e0c30caf941c0722fe1f33 (patch)
treedb0e907c2051b9f35efd1217b195ce2c2943b9e1 /usr.sbin/rpki-client
parent0ddfe2112515e50cb8324806313d2aa134a5ceb1 (diff)
Constrain KeyUsage and ExtendedKeyUsage on both CA & EE certificates
RFC 6487 section 4.8.4 restricts the KeyUsage extension on EE certificates to only be digitalSignature. RFC 6487 section 4.8.5 forbids the ExtendedKeyUsage extension from appearing on CA certificates. However, this may change in the future through the standardisation process. OK tb@
Diffstat (limited to 'usr.sbin/rpki-client')
-rw-r--r--usr.sbin/rpki-client/cert.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/usr.sbin/rpki-client/cert.c b/usr.sbin/rpki-client/cert.c
index c6fcec3cd30..cdd45e2ee1d 100644
--- a/usr.sbin/rpki-client/cert.c
+++ b/usr.sbin/rpki-client/cert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cert.c,v 1.91 2022/11/03 00:00:53 job Exp $ */
+/* $OpenBSD: cert.c,v 1.92 2022/11/03 10:39:19 job Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Copyright (c) 2021 Job Snijders <job@openbsd.org>
@@ -588,6 +588,18 @@ cert_parse_ee_cert(const char *fn, X509 *x)
if ((p.res = calloc(1, sizeof(struct cert))) == NULL)
err(1, NULL);
+ if (X509_get_key_usage(x) != KU_DIGITAL_SIGNATURE) {
+ warnx("%s: RFC 6487 section 4.8.4: KU must be digitalSignature",
+ fn);
+ goto out;
+ }
+
+ /* EKU may be allowed for some purposes in the future. */
+ if (X509_get_extended_key_usage(x) != UINT32_MAX) {
+ warnx("%s: RFC 6487 section 4.8.5: EKU not allowed", fn);
+ goto out;
+ }
+
index = X509_get_ext_by_NID(x, NID_sbgp_ipAddrBlock, -1);
if ((ext = X509_get_ext(x, index)) != NULL) {
if (!sbgp_ipaddrblk(&p, ext))
@@ -726,6 +738,14 @@ cert_parse_pre(const char *fn, const unsigned char *der, size_t len)
p.fn);
goto out;
}
+
+ /* EKU may be allowed for some purposes in the future. */
+ if (X509_get_extended_key_usage(x) != UINT32_MAX) {
+ warnx("%s: RFC 6487 section 4.8.5: EKU not allowed",
+ fn);
+ goto out;
+ }
+
if (p.res->mft == NULL) {
warnx("%s: RFC 6487 section 4.8.8: missing SIA", p.fn);
goto out;