Skip to content

Conversation

@vcsjones
Copy link
Member

@vcsjones vcsjones commented Jun 28, 2023

If an X500DistinguishedName contains an AttributeValue that is not a DirectoryString, the managed decoder will currently throw, catch the error, and return an empty string.

This changes the managed decoding to match the behavior of Windows. If an attribute is a binary value, then it is displayed in a hex encoded value, prefixed with a hash.

There is special handling if the binary value is an OCTET STRING. If the binary content is an octet string, the hex value displayed is the inner content. The outer OCTET STRING bytes are not displayed.

Fixes #88037.

Note: This only changes displaying binary content. Handling the reverse, parsing the strings like new X500DistinguishedName("CN=#1234") will be a separate pull request. That will be a breaking change on non-Windows, and we may decide not to take it. This pull request is not a breaking change and simply unblocks a scenario.

@vcsjones vcsjones requested a review from bartonjs June 28, 2023 14:49
@ghost ghost added the area-System.Security label Jun 28, 2023
@ghost ghost assigned vcsjones Jun 28, 2023
@ghost
Copy link

ghost commented Jun 28, 2023

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

If an X500DistinguishedName contains an AttributeValue that is not a DirectoryString, the managed decoder will currently throw, catch the error, and return an empty string.

This changes the managed decoding to match the behavior of Windows. If an attribute is a binary value, then it is displayed in a hex encoded value, prefixed with a hash.

There is special handling if the binary value is an OCTET STRING. If the binary content is an octet string, the hex value displayed is the inner content. The outer OCTET STRING bytes are not displayed.

Author: vcsjones
Assignees: vcsjones
Labels:

area-System.Security

Milestone: -

@vcsjones
Copy link
Member Author

Test failure is being tracked by #88172. Merging.

@vcsjones vcsjones merged commit d3d537f into dotnet:main Jun 29, 2023
@vcsjones vcsjones deleted the binary-attribute-values branch June 29, 2023 15:08
@vcsjones vcsjones added this to the 8.0.0 milestone Jun 29, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

X509Certificate2 class unable to read Subject data from some certificates on WSL/Docker containers/Linux

2 participants