Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

x509-cert: Document (or improve) how to construct `Name`

Aperta
#1,489 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@baloo ci sta già lavorando.

Dal 4/9/2024.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

enhancement

The yubikey crate's Certificate::generate_self_signed now takes subject as a Name, instead of &[RelativeDistinguishedName]. While I could migrate to RdnSequence(vec![...]), that makes use of the pub internals that prevent Name from being correct-by-construction per #1486, so I wanted to explore how Name can be constructed by a user who is just trying to use the yubikey crate, and may not be familiar at all with X.509 internals.

The documentation for Name just says "as defined in RFC 5280 Section 4.1.2.4". That section gives no indication about how a user can construct a Name; it instead describes the ASN.1 DER encoding of a Name.

The very first method that shows up on the doc page for Name is RdnSequence::encode_from_string, which:

  • Does not produce a Name (or even an RdnSequence).
  • Is marked as deprecated.

The only explicit constructor I can find for Name is impl FromStr for RdnSequence. This is documented as "Follows the rules in RFC 4514". Following that URL leads to a rather confusing set of rules, and no visible examples (because the datatracker HTML view does not show the contents at the top, and instead requires finding and clicking on the "Contents" tab on the right). Once I eventually found RFC 4514 Section 4: Examples I was on the right track (although I also had to refer back to the table at the bottom of section 3 for attribute types, which requires navigating past equally confusing specification syntax to find it).

Name should be given significantly more documentation, and more ergonomic constructors. Possibly a builder pattern would help? (That would save the extra allocation from format!(...).parse()?.)

At a minimum, there needs to be an example in the Name documentation of constructing it from a string. It would also be beneficial to describe the general syntax, and copy the table of attribute types, in either the FromStr implementation docs, or on Name itself (and then reference it from the FromStr impl).

(The above problems also apply to construction of RelativeDistinguishedName directly; this issue should address both in the same way.)

Lingua principale
Rust
Stelle
338
Fork
188
Merge medio
4g 6h
PR unite (30g)
15

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di RustCrypto/formats

Tutte le issue di RustCrypto/formats

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.