@@ -46,8 +46,45 @@ pub type Extensions = alloc::vec::Vec<Extension>;
46
46
47
47
/// Trait to be implemented by extensions to allow them to be formatted as x509 v3 extensions by
48
48
/// builder.
49
+ ///
50
+ /// # Examples
51
+ ///
52
+ /// ```
53
+ /// use const_oid::{AssociatedOid, ObjectIdentifier};
54
+ /// use x509_cert::{der::Sequence, ext, name};
55
+ ///
56
+ /// /// This extension indicates the age of the captain at the time of signature
57
+ /// #[derive(Clone, Debug, Eq, PartialEq, Sequence)]
58
+ /// pub struct CaptainAge {
59
+ /// pub age: u32,
60
+ /// }
61
+ ///
62
+ /// impl AssociatedOid for CaptainAge {
63
+ /// # // https://datatracker.ietf.org/doc/html/rfc5612
64
+ /// # // 32473 is the private OID reserved for documentation.
65
+ /// const OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.3.6.1.4.1.32473.1");
66
+ /// }
67
+ ///
68
+ /// impl ext::AsExtension for CaptainAge {
69
+ /// fn critical(&self, _subject: &name::Name, _extensions: &[ext::Extension]) -> bool {
70
+ /// false
71
+ /// }
72
+ /// }
73
+ /// ```
49
74
pub trait AsExtension : AssociatedOid + der:: Encode {
50
75
/// Should the extension be marked critical
76
+ ///
77
+ /// This affects the behavior of a validator when using the generated certificate.
78
+ /// See [RFC 5280 Section 4.2]:
79
+ /// ```text
80
+ /// A certificate-using system MUST reject the certificate if it encounters
81
+ /// a critical extension it does not recognize or a critical extension
82
+ /// that contains information that it cannot process. A non-critical
83
+ /// extension MAY be ignored if it is not recognized, but MUST be
84
+ /// processed if it is recognized.
85
+ /// ```
86
+ ///
87
+ /// [RFC 5280 Section 4.2]: https://www.rfc-editor.org/rfc/rfc5280#section-4.2
51
88
fn critical ( & self , subject : & crate :: name:: Name , extensions : & [ Extension ] ) -> bool ;
52
89
53
90
/// Returns the Extension with the content encoded.
0 commit comments