Skip to content

Commit cb1f025

Browse files
committed
Close #90, #361: Name Constraints (RFC5280 section 4.2.1.10)
Conversion of name constraints from certificate to Template (Advanced Tab) and using them from there was working since long. Now there is an additional input line, like (and next to) SubjectAlternativeName with live validation and edit button with guided input. The conversion from cert to template now puts the extension into the correct LineEdit and not on the Advanced Tab anymore. However, XCA does NOT follow the constraints, yet. It is still possible to issue certificates with arbitrary names, independent of any "Name Constraints" in the CA. This is what issue #239 asks for.
1 parent c6304a0 commit cb1f025

File tree

7 files changed

+195
-65
lines changed

7 files changed

+195
-65
lines changed

lib/func_base.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ D[NID_pkcs9_unstructuredName] = QObject::tr("Unstructured name");
244244
D[NID_pkcs9_challengePassword] = QObject::tr("Challenge password");
245245

246246
D[NID_basic_constraints] = QObject::tr("Basic Constraints");
247+
D[NID_name_constraints] = QObject::tr("Name Constraints");
247248
D[NID_subject_alt_name] = QObject::tr("Subject alternative name");
248249
D[NID_issuer_alt_name] = QObject::tr("issuer alternative name");
249250
D[NID_subject_key_identifier] = QObject::tr("Subject key identifier");

lib/pki_temp.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ namespace db {
5858
};
5959

6060
const QList<QString> pki_temp::tmpl_keys = {
61+
"nameCons",
6162
"subAltName",
6263
"issAltName",
6364
"crlDist",
@@ -223,6 +224,7 @@ extList pki_temp::fromCert(pki_x509super *cert_or_req)
223224
xname.addEntryByNid(nid, n.getEntry(i));
224225
}
225226

227+
fromExtList(&el, NID_name_constraints, "nameCons");
226228
fromExtList(&el, NID_subject_alt_name, "subAltName");
227229
fromExtList(&el, NID_issuer_alt_name, "issAltName");
228230
fromExtList(&el, NID_crl_distribution_points, "crlDist");

lib/x509v3ext.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ static bool nameConstraint(STACK_OF(GENERAL_SUBTREE) *trees,
924924
return true;
925925
}
926926

927-
bool x509v3ext::parse_nameConstraints(QString *, QString *adv) const
927+
bool x509v3ext::parse_nameConstraints(QString *single, QString *adv) const
928928
{
929929
bool retval = true;
930930
QString sect, ret;
@@ -947,11 +947,14 @@ bool x509v3ext::parse_nameConstraints(QString *, QString *adv) const
947947
if (ret.size() > 0)
948948
permEx << ret;
949949

950-
if (adv && retval &&permEx.size() > 0) {
950+
if (retval && permEx.size() > 0) {
951951
ret = permEx.join(", ");
952-
qDebug("%s %d '%s'\n", __func__, retval, CCHAR(ret));
953-
*adv = QString("%1=%2\n").arg(tag).
954-
arg(parse_critical() +ret) + *adv + sect;
952+
qDebug() << retval << ret;
953+
if (single)
954+
*single = ret;
955+
else if (adv)
956+
*adv = QString("%1=%2\n").arg(tag).
957+
arg(parse_critical() +ret) + *adv + sect;
955958
}
956959
NAME_CONSTRAINTS_free(cons);
957960
return retval;

0 commit comments

Comments
 (0)