-
Notifications
You must be signed in to change notification settings - Fork 77
Description
While comparing GeneralNames, I noticed that the implementation of GeneralName may not adhere to the these RFCs:
Looking at the implementation
x509-parser/src/extensions/generalname.rs
Lines 30 to 35 in b28b903
| pub enum GeneralName<'a> { | |
| OtherName(Oid<'a>, Any<'a>), | |
| /// More or less an e-mail, the format is not checked. | |
| RFC822Name(&'a str), | |
| /// A hostname, format is not checked. | |
| DNSName(&'a str), |
the DNSName field stores a &'a str which may be UTF-8 in Rust, but says RFC5280 7.2
one choice in GeneralName is the dNSName field, which is defined as type IA5String. [...] IA5String is limited to the set of ASCII characters. [...]
Moreover, the comparison of a &str is case-sensitive, while RFC1034 3.5 says
Note that while upper and lower case letters are allowed in domain names, no significance is attached to the case. That is, two names with the same spelling but different case are to be treated as if identical.
I am not 100% sure, but according to the RFC, we may need a case-insentive comparison here. Since PartialEq is derived, a new-type pattern could suffice for an ASCII-string that does case-insensitive comparisons.