-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve handling of encoding of X.520 attributes #109349
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vcsjones
added
area-System.Security
breaking-change
Issue or PR that represents a breaking API or functional change over a prerelease.
labels
Oct 29, 2024
dotnet-policy-service
bot
added
the
needs-breaking-change-doc-created
Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet
label
Oct 29, 2024
bartonjs
reviewed
Oct 29, 2024
bartonjs
reviewed
Oct 29, 2024
...m.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X500NameEncoder.cs
Show resolved
Hide resolved
bartonjs
reviewed
Oct 29, 2024
...m.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X500NameEncoder.cs
Outdated
Show resolved
Hide resolved
bartonjs
reviewed
Oct 29, 2024
...m.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X500NameEncoder.cs
Outdated
Show resolved
Hide resolved
bartonjs
reviewed
Oct 31, 2024
...m.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X500NameEncoder.cs
Outdated
Show resolved
Hide resolved
bartonjs
approved these changes
Oct 31, 2024
I'll make the breaking change doc in the next day or two. |
Breaking change doc: dotnet/docs#43284 |
vcsjones
removed
the
needs-breaking-change-doc-created
Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet
label
Nov 1, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-System.Security
breaking-change
Issue or PR that represents a breaking API or functional change over a prerelease.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Our managed encoder for distinguished names took a loose approach to encoding names which could result in violating the encoding rules of certain X.520 attributes. For example, the "countryName" attribute (2.5.4.6) is a PrintableString, and only a PrintableString. However, the
ForceUTF8Encoding
flag would result in a UTF8String, which is not permitted.This PR brings our managed encoder to align more similarly with Windows, but makes some deviations.
ForceUTF8Encoding
flag will only work on things that can be encoded as UTF-8. That meansDirectoryString
and attributes that are unknown.ForceUTF8String
, we would encode something as a UTF8String if it could not be represented as a PrintableString. Now, if you attempt to encode a PrintableString (or NumericString) with characters that are outside of the encoding rules, an exception is thrown instead of promoting it to UTF-8. This behavior matches Windows and aligns more with the specification. It is a breaking change however.I expect few if anyone to be bothered by the stricter encoding requirements. Windows already had them, with the exception of two attributes (countryName3C and countryName3N). The breaking change doc will explain developers can use
X500DistinguishedNameBuilder
which offers an escape hatch and overriding of opinions on how to encode a particular component.Fixes #109156