identification: Only use either , or / to separate RDNs
If a DN starts with a slash (or whitespace and a slash) slashes will be used, otherwise commas.
This commit is contained in:
1 parent
846fd70eec
commit
aba55fdffe
2 files changed
+17
-7
No files matched your search
@@ -376,14 +376,14 @@ START_TEST(test_equals)
|
|||||||
"C=CH, E=moon@strongswan.org, CN=moon");
|
"C=CH, E=moon@strongswan.org, CN=moon");
|
||||||
|
|
||||||
ck_assert(id_equals(a, "C=CH, E=moon@strongswan.org, CN=moon"));
|
ck_assert(id_equals(a, "C=CH, E=moon@strongswan.org, CN=moon"));
|
||||||
ck_assert(id_equals(a, "C==CH, E==moon@strongswan.org,,, CN==moon"));
|
ck_assert(id_equals(a, "C==CH , E==moon@strongswan.org , CN==moon"));
|
||||||
ck_assert(id_equals(a, " C=CH, E=moon@strongswan.org, CN=moon "));
|
ck_assert(id_equals(a, " C=CH, E=moon@strongswan.org, CN=moon "));
|
||||||
ck_assert(id_equals(a, "C=ch, E=moon@STRONGSWAN.ORG, CN=Moon"));
|
ck_assert(id_equals(a, "C=ch, E=moon@STRONGSWAN.ORG, CN=Moon"));
|
||||||
ck_assert(id_equals(a, "/C=CH/E=moon@strongswan.org/CN=moon"));
|
ck_assert(id_equals(a, "/C=CH/E=moon@strongswan.org/CN=moon"));
|
||||||
ck_assert(id_equals(a, "C=CH/E=moon@strongswan.org/CN=moon"));
|
ck_assert(id_equals(a, " / C=CH / E=moon@strongswan.org / CN=moon"));
|
||||||
ck_assert(id_equals(a, "C=CH/E=moon@strongswan.org,CN=moon"));
|
|
||||||
ck_assert(id_equals(a, "C=CH / E=moon@strongswan.org , CN=moon"));
|
|
||||||
|
|
||||||
|
ck_assert(!id_equals(a, "C=CH/E=moon@strongswan.org/CN=moon"));
|
||||||
|
ck_assert(!id_equals(a, "C=CH/E=moon@strongswan.org,CN=moon"));
|
||||||
ck_assert(!id_equals(a, "C=CH E=moon@strongswan.org CN=moon"));
|
ck_assert(!id_equals(a, "C=CH E=moon@strongswan.org CN=moon"));
|
||||||
ck_assert(!id_equals(a, "C=CN, E=moon@strongswan.org, CN=moon"));
|
ck_assert(!id_equals(a, "C=CN, E=moon@strongswan.org, CN=moon"));
|
||||||
ck_assert(!id_equals(a, "E=moon@strongswan.org, C=CH, CN=moon"));
|
ck_assert(!id_equals(a, "E=moon@strongswan.org, C=CH, CN=moon"));
|
||||||
|
|||||||
@@ -394,14 +394,24 @@ static status_t atodn(char *src, chunk_t *dn)
|
|||||||
asn1_t rdn_type;
|
asn1_t rdn_type;
|
||||||
state_t state = SEARCH_OID;
|
state_t state = SEARCH_OID;
|
||||||
status_t status = SUCCESS;
|
status_t status = SUCCESS;
|
||||||
|
char sep = '\0';
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case SEARCH_OID:
|
case SEARCH_OID:
|
||||||
if (*src != ' ' && *src != '/' && *src != ',' && *src != '\0')
|
if (!sep && *src == '/')
|
||||||
|
{ /* use / as separator if the string starts with a slash */
|
||||||
|
sep = '/';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*src != ' ' && *src != '\0')
|
||||||
{
|
{
|
||||||
|
if (!sep)
|
||||||
|
{ /* use , as separator by default */
|
||||||
|
sep = ',';
|
||||||
|
}
|
||||||
oid.ptr = src;
|
oid.ptr = src;
|
||||||
oid.len = 1;
|
oid.len = 1;
|
||||||
state = READ_OID;
|
state = READ_OID;
|
||||||
@@ -441,7 +451,7 @@ static status_t atodn(char *src, chunk_t *dn)
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (*src != ',' && *src != '/' && *src != '\0')
|
else if (*src != sep && *src != '\0')
|
||||||
{
|
{
|
||||||
name.ptr = src;
|
name.ptr = src;
|
||||||
name.len = 1;
|
name.len = 1;
|
||||||
@@ -454,7 +464,7 @@ static status_t atodn(char *src, chunk_t *dn)
|
|||||||
state = READ_NAME;
|
state = READ_NAME;
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
case READ_NAME:
|
case READ_NAME:
|
||||||
if (*src != ',' && *src != '/' && *src != '\0')
|
if (*src != sep && *src != '\0')
|
||||||
{
|
{
|
||||||
name.len++;
|
name.len++;
|
||||||
if (*src == ' ')
|
if (*src == ' ')
|
||||||
|
|||||||
Reference in new issue
Block a user