crypt32: Implement wildcard domain name matching in subject alternative names.
authorJuan Lang <juan.lang@gmail.com>
Thu, 20 May 2010 15:52:43 +0000 (08:52 -0700)
committerAlexander Morozov <amorozov@etersoft.ru>
Thu, 1 Jul 2010 13:18:20 +0000 (17:18 +0400)
dlls/crypt32/chain.c
dlls/crypt32/tests/chain.c

index d324314e9e2d2d9ced9373e1ec5b8ba792a0d457..e951ef8e9c51ded4cf23315808372058760f6339 100644 (file)
@@ -3035,7 +3035,31 @@ static BOOL match_dns_to_subject_alt_name(PCERT_EXTENSION ext,
             {
                 TRACE_(chain)("dNSName: %s\n", debugstr_w(
                  subjectName->rgAltEntry[i].u.pwszDNSName));
-                if (!strcmpiW(server_name,
+                if (subjectName->rgAltEntry[i].u.pwszDNSName[0] == '*')
+                {
+                    LPCWSTR server_name_dot;
+
+                    /* Matching a wildcard: a wildcard matches a single name
+                     * component, which is terminated by a dot.  RFC 1034
+                     * doesn't define whether multiple wildcards are allowed,
+                     * but I will assume that they are not until proven
+                     * otherwise.  RFC 1034 also states that 'the "*" label
+                     * always matches at least one whole label and sometimes
+                     * more, but always whole labels.'  Native crypt32 does not
+                     * match more than one label with a wildcard, so I do the
+                     * same here.  Thus, a wildcard only accepts the first
+                     * label, then requires an exact match of the remaining
+                     * string.
+                     */
+                    server_name_dot = strchrW(server_name, '.');
+                    if (server_name_dot)
+                    {
+                        if (!strcmpiW(server_name_dot,
+                         subjectName->rgAltEntry[i].u.pwszDNSName + 1))
+                            matches = TRUE;
+                    }
+                }
+                else if (!strcmpiW(server_name,
                  subjectName->rgAltEntry[i].u.pwszDNSName))
                     matches = TRUE;
             }
index 0484aa1ca4abb26f61d34d45da690fc2e8bd6b0c..a59a95a0bb1bb9d657066499c01a8c261723004c 100644 (file)
@@ -3818,7 +3818,7 @@ static const ChainPolicyCheck opensslPolicyCheckWithoutMatchingName = {
 
 static const ChainPolicyCheck winehqPolicyCheckWithMatchingName = {
  { sizeof(chain29) / sizeof(chain29[0]), chain29 },
- { 0, 0, -1, -1, NULL}, NULL, TODO_ERROR
+ { 0, 0, -1, -1, NULL}, NULL, 0
 };
 
 static const ChainPolicyCheck winehqPolicyCheckWithoutMatchingName = {