Skip to content

Commit 61fe940

Browse files
committed
rework AsExtension trait?
1 parent d87a3a2 commit 61fe940

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-0
lines changed

x509-cert/src/ext/pkix.rs

+11
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ impl AssociatedOid for SubjectAltName {
6565
}
6666

6767
impl_newtype!(SubjectAltName, name::GeneralNames);
68+
// TODO(baloo): apply that?
69+
// Further, if the only subject identity included in the certificate is
70+
// an alternative name form (e.g., an electronic mail address), then the
71+
// subject distinguished name MUST be empty (an empty sequence), and the
72+
// subjectAltName extension MUST be present. If the subject field
73+
// contains an empty sequence, then the issuing CA MUST include a
74+
// subjectAltName extension that is marked as critical. When including
75+
// the subjectAltName extension in a certificate that has a non-empty
76+
// subject distinguished name, conforming CAs SHOULD mark the
77+
// subjectAltName extension as non-critical.
78+
impl_extension!(SubjectAltName);
6879

6980
/// IssuerAltName as defined in [RFC 5280 Section 4.2.1.7].
7081
///

x509-cert/src/ext/pkix/certpolicy.rs

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ impl AssociatedOid for CertificatePolicies {
2222
}
2323

2424
impl_newtype!(CertificatePolicies, Vec<PolicyInformation>);
25+
// TODO
26+
// If this extension is
27+
// critical, the path validation software MUST be able to interpret this
28+
// extension (including the optional qualifier), or MUST reject the
29+
// certificate.
30+
impl_extension!(CertificatePolicies);
2531

2632
/// PolicyInformation as defined in [RFC 5280 Section 4.2.1.4].
2733
///

x509-cert/src/ext/pkix/constraints/basic.rs

+14
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,17 @@ pub struct BasicConstraints {
2222
impl AssociatedOid for BasicConstraints {
2323
const OID: ObjectIdentifier = ID_CE_BASIC_CONSTRAINTS;
2424
}
25+
26+
// TODO
27+
// Conforming CAs MUST include this extension in all CA certificates
28+
// that contain public keys used to validate digital signatures on
29+
// certificates and MUST mark the extension as critical in such
30+
// certificates. This extension MAY appear as a critical or non-
31+
// critical extension in CA certificates that contain public keys used
32+
// exclusively for purposes other than validating digital signatures on
33+
// certificates. Such CA certificates include ones that contain public
34+
// keys used exclusively for validating digital signatures on CRLs and
35+
// ones that contain key management public keys used with certificate
36+
// enrollment protocols. This extension MAY appear as a critical or
37+
// non-critical extension in end entity certificates.
38+
impl_extension!(BasicConstraints, critical = true);

x509-cert/src/ext/pkix/constraints/name.rs

+11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ pub struct NameConstraints {
3030
impl AssociatedOid for NameConstraints {
3131
const OID: ObjectIdentifier = ID_CE_NAME_CONSTRAINTS;
3232
}
33+
// TODO: whatever that means:
34+
// Restrictions are defined in terms of permitted or excluded name
35+
// subtrees. Any name matching a restriction in the excludedSubtrees
36+
// field is invalid regardless of information appearing in the
37+
// permittedSubtrees. Conforming CAs MUST mark this extension as
38+
// critical and SHOULD NOT impose name constraints on the x400Address,
39+
// ediPartyName, or registeredID name forms. Conforming CAs MUST NOT
40+
// issue certificates where name constraints is an empty sequence. That
41+
// is, either the permittedSubtrees field or the excludedSubtrees MUST
42+
// be present.
43+
impl_extension!(NameConstraints);
3344

3445
/// GeneralSubtrees as defined in [RFC 5280 Section 4.2.1.10].
3546
///

x509-cert/src/ext/pkix/keyusage.rs

+14
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,20 @@ impl AssociatedOid for ExtendedKeyUsage {
7878
}
7979

8080
impl_newtype!(ExtendedKeyUsage, Vec<ObjectIdentifier>);
81+
// TODO
82+
// This extension MAY, at the option of the certificate issuer, be
83+
// either critical or non-critical.
84+
//
85+
// If a CA includes extended key usages to satisfy such applications,
86+
// but does not wish to restrict usages of the key, the CA can include
87+
// the special KeyPurposeId anyExtendedKeyUsage in addition to the
88+
// particular key purposes required by the applications. Conforming CAs
89+
// SHOULD NOT mark this extension as critical if the anyExtendedKeyUsage
90+
// KeyPurposeId is present. Applications that require the presence of a
91+
// particular purpose MAY reject certificates that include the
92+
// anyExtendedKeyUsage OID but not the particular OID expected for the
93+
// application.
94+
impl_extension!(ExtendedKeyUsage, critical = true);
8195

8296
/// PrivateKeyUsagePeriod as defined in [RFC 3280 Section 4.2.1.4].
8397
///

0 commit comments

Comments
 (0)