-
Notifications
You must be signed in to change notification settings - Fork 69
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
Added support for parsing challenge password attribute in CSR's #129
Added support for parsing challenge password attribute in CSR's #129
Conversation
A remark @chifflier: I think, the attribute parsing could be improved. Currently, pub struct X509CriAttribute<'a> {
pub oid: Oid<'a>,
pub value: &'a [u8],
pub(crate) parsed_attribute: ParsedCriAttribute<'a>,
} Why is that? A user of the x509-parser crate needs to re-parse |
I just compared impl<'a> X509Extension<'a> {
...
/// Return the extension type or `UnsupportedExtension` if the extension is not implemented.
#[inline]
pub fn parsed_extension(&self) -> &ParsedExtension<'a> {
&self.parsed_extension
}
} We could do that in a similar manner for attributes impl<'a> CriAttribute<'a> {
...
/// Return the attribute type or `UnsupportedAttribute` if the attribute is unknown.
#[inline]
pub fn parsed_attribute(&self) -> &ParsedCriAttribute<'a> {
&self.parsed_attribute
}
} |
I will check my proposal and set this request to draft. |
Seems to work. |
@chifflier The checks will fail until oid-registry with OID for challenge password is released. |
oid-registry 0.6.1 has just been released with the required OID |
src/cri_attributes.rs
Outdated
// I'm sure, there is a more elegant way to try multiple parsers until the first succeeds, | ||
// but I don't know nom well enough to implement it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the PR looks fine, thanks!
Can you rebase to the latest master (now that oid-registry
is released) and address the minor point in comment before merge?
src/cri_attributes.rs
Outdated
match obj.content { | ||
BerObjectContent::PrintableString(s) | BerObjectContent::UTF8String(s) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something like
match obj.as_str() {
Ok(s) => Ok((rem, ChallengePassword { 0: s.to_string() })),
// ...
is slightly more elegant and does not require to enumerate variants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks. However, digging into RFC 2985, 5.2.2 I saw, that all string types should be supported (not only the recommended PrintableString
and UTF8String
). I extended the parser with the other types using nom::branch::alt
.
tests/readcsr.rs
Outdated
let (i, challenge_password) = String::from_der(i)?; | ||
Ok((i, challenge_password)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that exactly the same as just String::from_der(i)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think your right. I'll fix that.
Changes are implemented. Thanks for reviewing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great now, thanks for your patience!
I will merge it as soon as possible
This branch adds support for parsing a challenge password attribute in a CSR.
Please note: rusticata/oid-registry#10 is a prerequisite, as it adds
OID_PKCS9_CHALLENGE_PASSWORD
. This PR is merged, but not yet released.