Skip to content

Commit abd1e36

Browse files
authored
Merge pull request #7420 from anhu/cmp_name_case
When comparing subject names, do not worry about case.
2 parents 1d1800a + 4ddba7a commit abd1e36

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/x509.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11159,7 +11159,7 @@ int wolfSSL_i2d_X509_NAME(WOLFSSL_X509_NAME* name, unsigned char** out)
1115911159
_x = (x->name && *x->name) ? x->name : x->staticName;
1116011160
_y = (y->name && *y->name) ? y->name : y->staticName;
1116111161

11162-
return XSTRNCMP(_x, _y, x->sz); /* y sz is the same */
11162+
return XSTRNCASECMP(_x, _y, x->sz); /* y sz is the same */
1116311163
}
1116411164

1116511165
#ifndef NO_BIO

tests/api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12374,6 +12374,16 @@ static int test_wolfSSL_PKCS12(void)
1237412374
ExpectIntEQ(wolfSSL_X509_NAME_cmp((const WOLFSSL_X509_NAME*)subject,
1237512375
(const WOLFSSL_X509_NAME*)wolfSSL_X509_get_subject_name(x509)), 0);
1237612376

12377+
/* modify case and compare subject from certificate in ca to expected.
12378+
* The first bit of the name is:
12379+
* /C=US/ST=Washington
12380+
* So we'll change subject->name[1] to 'c' (lower case) */
12381+
if (subject != NULL) {
12382+
subject->name[1] = 'c';
12383+
ExpectIntEQ(wolfSSL_X509_NAME_cmp((const WOLFSSL_X509_NAME*)subject,
12384+
(const WOLFSSL_X509_NAME*)wolfSSL_X509_get_subject_name(x509)), 0);
12385+
}
12386+
1237712387
EVP_PKEY_free(pkey);
1237812388
pkey = NULL;
1237912389
X509_free(x509);

0 commit comments

Comments
 (0)