-/* $OpenBSD: cert.c,v 1.108 2023/05/09 10:34:32 tb Exp $ */
+/* $OpenBSD: cert.c,v 1.109 2023/06/20 12:28:08 job Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Copyright (c) 2021 Job Snijders <job@openbsd.org>
if ((p.res = calloc(1, sizeof(struct cert))) == NULL)
err(1, NULL);
+ if (X509_get_version(x) != 2) {
+ warnx("%s: RFC 6487 4.1: X.509 version must be v3", fn);
+ goto out;
+ }
+
if (X509_get_key_usage(x) != KU_DIGITAL_SIGNATURE) {
warnx("%s: RFC 6487 section 4.8.4: KU must be digitalSignature",
fn);
goto out;
}
+ if (X509_get_version(x) != 2) {
+ warnx("%s: RFC 6487 4.1: X.509 version must be v3", fn);
+ goto out;
+ }
+
X509_get0_signature(NULL, &palg, x);
if (palg == NULL) {
cryptowarnx("%s: X509_get0_signature", p.fn);