Skip to content
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

feat: support non utf8 strings #71

Merged
merged 2 commits into from
Jan 20, 2022
Merged

feat: support non utf8 strings #71

merged 2 commits into from
Jan 20, 2022

Conversation

omjadas
Copy link
Contributor

@omjadas omjadas commented Jan 16, 2022

fixes #59
Allows non UTF-8 values to be used for distinguished name entries

Copy link
Member

@est31 est31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! This is an API breaking change, so requires a minor semver bump for a future release. Not sure yet if I want to wait with merging or merge it right now.

src/lib.rs Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated
@@ -414,11 +427,11 @@ impl DistinguishedName {
removed
}
/// Inserts or updates an attribute that consists of type and name
pub fn push(&mut self, ty :DnType, s :impl Into<String>) {
pub fn push(&mut self, ty :DnType, s :DnValue) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to keep the old API for the push side, as 99% of use cases would probably be UTF-8 strings. This doesn't just reduce the diff of this PR but also makes updating easier for the users. Usage of the API would also remain as easy as it used to be. Can you rename this function to push_ext or something and say something along the lines that you should use push unless there is a specific need to use something other than Utf8Strings?

The get side is fine, as I think it's less used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to have a single method that takes an impl Into<DnValue> and provide the following implementation?

impl<T> From<T> for DnValue
where
	T :Into<String>
{
	fn from(t :T) -> Self {
		DnValue::Utf8String(t.into())
	}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to have a single method that takes an impl Into and provide the following implementation?

That's a great idea! I'm a bit worried though that the impl is not immediately seen. A code example in the rustdoc that uses a str literal would solve that I think.

@omjadas
Copy link
Contributor Author

omjadas commented Jan 18, 2022

@est31 I have updated the PR per your suggestions. Let me know if you would prefer push to be split into separate methods and I can make the change.

@est31
Copy link
Member

est31 commented Jan 18, 2022

Also I'd like to see a test case for #59. Ideally it'd not use a certificate from the wild due to copyright but one you generated yourself (maybe even using rcgen). As for the breaking change, one of the possible resolutions of #65 seems to require one already, and the ring author said they wanted to make a breaking change themselves soon.

@omjadas
Copy link
Contributor Author

omjadas commented Jan 19, 2022

@est31 I have added the requested example and tests. Let me know if there is anything else you would like changed/added.

Copy link
Member

@est31 est31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK except for nits.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@est31 est31 merged commit 2335888 into rustls:master Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loading CA cert and using for signing doesn't match original certificate
2 participants