summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2022-03-13 16:48:49 +0000
committertb <>2022-03-13 16:48:49 +0000
commitd2b2d2e01cc3df4a8f0ef3f63554c01984029988 (patch)
tree5986b435064314080bd34bdb3b8bb0ffef936677
parent0c527fae0adcddaf5e804393d71c0fe901c0b247 (diff)
downloadopenbsd-d2b2d2e01cc3df4a8f0ef3f63554c01984029988.tar.gz
openbsd-d2b2d2e01cc3df4a8f0ef3f63554c01984029988.tar.bz2
openbsd-d2b2d2e01cc3df4a8f0ef3f63554c01984029988.zip
Check name constraints using the proper API
The previous versions were too strict and disallowed leading dots. From Alex Wilson ok jsing
-rw-r--r--src/lib/libcrypto/x509/x509_alt.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/lib/libcrypto/x509/x509_alt.c b/src/lib/libcrypto/x509/x509_alt.c
index addf300a2a..35aae6f185 100644
--- a/src/lib/libcrypto/x509/x509_alt.c
+++ b/src/lib/libcrypto/x509/x509_alt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_alt.c,v 1.9 2022/03/13 16:30:31 tb Exp $ */ 1/* $OpenBSD: x509_alt.c,v 1.10 2022/03/13 16:48:49 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -652,7 +652,25 @@ v2i_GENERAL_NAME_ex(GENERAL_NAME *out, const X509V3_EXT_METHOD *method,
652 if (ret == NULL) 652 if (ret == NULL)
653 return NULL; 653 return NULL;
654 654
655 /* Validate what we have for sanity */ 655 /*
656 * Validate what we have for sanity.
657 */
658
659 if (is_nc) {
660 struct x509_constraints_name constraints_name;
661 int error = 0;
662
663 memset(&constraints_name, 0, sizeof(constraints_name));
664 type = x509_constraints_validate(ret, &constraints_name, &error);
665 if (type == 0 || error != 0) {
666 X509V3error(X509V3_R_BAD_OBJECT);
667 ERR_asprintf_error_data("name=%s", name);
668 goto err;
669 }
670 x509_constraints_name_clear(&constraints_name);
671 return ret;
672 }
673
656 type = x509_constraints_general_to_bytes(ret, &bytes, &len); 674 type = x509_constraints_general_to_bytes(ret, &bytes, &len);
657 switch (type) { 675 switch (type) {
658 case GEN_DNS: 676 case GEN_DNS:
@@ -677,8 +695,7 @@ v2i_GENERAL_NAME_ex(GENERAL_NAME *out, const X509V3_EXT_METHOD *method,
677 } 695 }
678 break; 696 break;
679 case GEN_IPADD: 697 case GEN_IPADD:
680 if ((!is_nc && len != 4 && len != 16) || 698 if (len != 4 && len != 16) {
681 (is_nc && len != 8 && len != 32)) {
682 X509V3error(X509V3_R_BAD_IP_ADDRESS); 699 X509V3error(X509V3_R_BAD_IP_ADDRESS);
683 ERR_asprintf_error_data("name=%s len=%zu", name, len); 700 ERR_asprintf_error_data("name=%s len=%zu", name, len);
684 goto err; 701 goto err;