Skip to content

Commit 8e637f6

Browse files
authored
x509-cert: support for GN in names (#1648)
* oiddbgen: allow comments in the ldap database * const-oid: support for GN as an alias to givenName * x509-cert: test support for givenName
1 parent babd629 commit 8e637f6

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

const-oid/oiddbgen/ldap-parameters-3.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ generalizedTimeMatch,M,2.5.13.27,[RFC4517]
201201
generalizedTimeOrderingMatch,M,2.5.13.28,[RFC4517]
202202
generationQualifier,A,2.5.4.44,[RFC4519]
203203
givenName,A,2.5.4.42,[RFC4519]
204-
GN,A,RESERVED,[RFC4519]
204+
GN,A,2.5.4.42,[RFC4519],"should be reserved, overridden. context: issue_1647"
205205
governingStructureRule,A,2.5.21.10,[RFC4512]
206206
groupOfNames,O,2.5.6.9,[RFC4519]
207207
groupOfUniqueNames,O,2.5.6.17,[RFC4519]

const-oid/oiddbgen/src/ldap.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ impl<'a> LdapParser<'a> {
1010
self.0.lines().filter_map(|line| {
1111
let (name, next) = line.split_at(line.find(',').unwrap());
1212
let (.., next) = next[1..].split_at(next[1..].find(',').unwrap());
13-
let (obid, spec) = next[1..].split_at(next[1..].find(',').unwrap());
13+
let (obid, next) = next[1..].split_at(next[1..].find(',').unwrap());
1414

1515
let indx = obid.find('.')?;
1616
obid.split_at(indx).0.parse::<usize>().ok()?;
1717

18+
let spec = if let Some(boundary) = next[1..].find(',') {
19+
let (spec, _comment) = next[..].split_at(boundary + 1);
20+
spec
21+
} else {
22+
next
23+
};
24+
1825
if !spec.trim().starts_with(",[RFC") {
1926
return None;
2027
}

const-oid/src/db/gen.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,7 @@ pub mod rfc4519 {
15431543
pub const SN: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.4");
15441544
pub const SURNAME: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.4");
15451545
pub const NAME: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.41");
1546+
pub const GN: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.42");
15461547
pub const GIVEN_NAME: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.42");
15471548
pub const INITIALS: crate::ObjectIdentifier = crate::ObjectIdentifier::new_unwrap("2.5.4.43");
15481549
pub const GENERATION_QUALIFIER: crate::ObjectIdentifier =
@@ -4373,6 +4374,7 @@ pub const DB: super::Database<'static> = super::Database(&[
43734374
(&rfc4519::SN, "sn"),
43744375
(&rfc4519::SURNAME, "surname"),
43754376
(&rfc4519::NAME, "name"),
4377+
(&rfc4519::GN, "GN"),
43764378
(&rfc4519::GIVEN_NAME, "givenName"),
43774379
(&rfc4519::INITIALS, "initials"),
43784380
(&rfc4519::GENERATION_QUALIFIER, "generationQualifier"),

x509-cert/tests/name.rs

+9
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,12 @@ fn access_attributes() {
410410
"US"
411411
);
412412
}
413+
414+
#[cfg(feature = "std")]
415+
#[test]
416+
fn decode_given_name() {
417+
use std::str::FromStr;
418+
419+
Name::from_str("GN=my_name,SN=my_sn").unwrap();
420+
Name::from_str("givenName=my_name,SN=my_sn").unwrap();
421+
}

0 commit comments

Comments
 (0)