Skip to content

Commit

Permalink
Permit incorrectly DER sorted SET for decoding X500 names. (dotnet#32604
Browse files Browse the repository at this point in the history
)

* Permit incorrectly DER sorted SET for decoding X500 names.

* Add comment to explain.
  • Loading branch information
vcsjones authored Feb 20, 2020
1 parent c04271b commit b12c901
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ private static string X500DistinguishedNameDecode(

while (x500NameSequenceReader.HasData)
{
rdnReaders.Add(x500NameSequenceReader.ReadSetOf());
// To match Windows' behavior, permit multi-value RDN SETs to not
// be DER sorted.
rdnReaders.Add(x500NameSequenceReader.ReadSetOf(skipSortOrderValidation: true));
}

// We need to allocate a StringBuilder to hold the data as we're building it, and there's the usual
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ public static void NameWithNumericString()
Assert.Equal("OID.1.1.1.2.2.3=123 654 7890, CN=Test", dn.Decode(X500DistinguishedNameFlags.None));
}

[Fact]
public static void OrganizationUnitMultiValueWithIncorrectlySortedDerSet()
{
X500DistinguishedName dn = new X500DistinguishedName(
"301C311A300B060355040B13047A7A7A7A300B060355040B130461616161".HexToByteArray());

Assert.Equal("OU=zzzz + OU=aaaa", dn.Decode(X500DistinguishedNameFlags.None));
}

public static readonly object[][] WhitespaceBeforeCases =
{
// Regular space.
Expand Down

0 comments on commit b12c901

Please sign in to comment.