Skip to content

Commit e7b7fdd

Browse files
committed
Apply DNS constraints to subject CN when SAN is not available.
1 parent b17755b commit e7b7fdd

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17658,9 +17658,16 @@ static int ConfirmNameConstraints(Signer* signer, DecodedCert* cert)
1765817658
XMEMSET(&subjectDnsName, 0, sizeof(DNS_entry));
1765917659
switch (nameType) {
1766017660
case ASN_DNS_TYPE:
17661-
/* Should it also consider CN in subject? It could use
17662-
* subjectDnsName too */
1766317661
name = cert->altNames;
17662+
17663+
/* When no SAN is present, apply DNS name constraints to the
17664+
* Subject CN. */
17665+
if (cert->subjectCN != NULL && cert->altNames == NULL) {
17666+
subjectDnsName.next = NULL;
17667+
subjectDnsName.type = ASN_DNS_TYPE;
17668+
subjectDnsName.len = cert->subjectCNLen;
17669+
subjectDnsName.name = cert->subjectCN;
17670+
}
1766417671
break;
1766517672
case ASN_IP_TYPE:
1766617673
/* IP addresses are stored in altNames with type ASN_IP_TYPE */

0 commit comments

Comments
 (0)