diff --git a/certs/test/cert-ext-ndir-exc.cfg b/certs/test/cert-ext-ndir-exc.cfg new file mode 100644 index 000000000..8d66b8a07 --- /dev/null +++ b/certs/test/cert-ext-ndir-exc.cfg @@ -0,0 +1,24 @@ +[ req ] +distinguished_name = req_distinguished_name +prompt = no +x509_extensions = constraints + +[ req_distinguished_name ] +C = US +ST = Montana +L = Bozeman +O = Sawtooth +OU = Consulting +CN = www.wolfssl.com +emailAddress = info@wolfsssl.com + +[constraints] +subjectKeyIdentifier=hash +authorityKeyIdentifier=keyid:always,issuer:always +basicConstraints=CA:TRUE +nameConstraints=critical,excluded;dirName:dir_name_exclude + +[dir_name_exclude] +countryName = US +stateOrProvinceName = California + diff --git a/certs/test/cert-ext-ndir-exc.der b/certs/test/cert-ext-ndir-exc.der new file mode 100644 index 000000000..19afbab84 Binary files /dev/null and b/certs/test/cert-ext-ndir-exc.der differ diff --git a/certs/test/gen-ext-certs.sh b/certs/test/gen-ext-certs.sh index 65ce2124c..e418157ab 100755 --- a/certs/test/gen-ext-certs.sh +++ b/certs/test/gen-ext-certs.sh @@ -128,3 +128,35 @@ countryName = US EOF gen_cert +OUT=certs/test/cert-ext-ndir-exc.der +KEYFILE=certs/ca-key.der +CONFIG=certs/test/cert-ext-ndir-exc.cfg +tee >$CONFIG <nameSz) == 0) { return 0; } + #ifndef WOLFSSL_NO_ASN_STRICT + /* RFC 5280 section 4.2.1.10 + "Restrictions of the form directoryName MUST be + applied to the subject field .... and to any names + of type directoryName in the subjectAltName + extension" + */ + if (cert->altDirNames != NULL) { + DNS_entry* cur = cert->altDirNames; + while (cur != NULL) { + if (XMEMCMP(cur->name, base->name, base->nameSz) + == 0) { + WOLFSSL_MSG("DIR alt name constraint err"); + return 0; + } + cur = cur->next; + } + } + #endif /* !WOLFSSL_NO_ASN_STRICT */ break; } }; /* switch */