pub struct Cert {
pub subject: Identity,
pub context: Hash,
pub key: String,
pub val: String,
pub seq: u64,
pub start: Timestamp,
pub end: Timestamp,
pub valid: bool,
pub revokes: Option<CertReplace>,
}
Expand description
A certificate, which can be encoded as a fog-pack
Document
and signed.
A certificate is valid for a matching subject/context/key if:
- the current time is between the start & end times
- “valid” is set to true
A certificate database generally only keeps one certificate for a given subject/context/key/signer combination. When deciding which of two certificates to keep, it should do the following:
- Pick the one with the higher start time
- If start times match, pick the one with the higher sequence number
- If the sequence numbers also match, prefer the stored one.
A database should also record the highest end time it has seen for a given certificate combo, as this lets it know when it can discard the certificate.
Sometimes, issuing this certificate requires that another be revoked at the same time - for instance, if an authority is being transferred. In this case, a “revokes” option should be added that details the revocation of another certificate. If the revocation rule is valid and can be executed successfully by the database, then this certificate is valid. Otherwise, this certificate shouldn’t be accepted.
Fields§
§subject: Identity
§context: Hash
§key: String
§val: String
§seq: u64
§start: Timestamp
§end: Timestamp
§valid: bool
§revokes: Option<CertReplace>
Implementations§
Source§impl Cert
impl Cert
Sourcepub fn is_valid(&self, time: Option<Timestamp>) -> bool
pub fn is_valid(&self, time: Option<Timestamp>) -> bool
Check for validity. If no time is provided, the start & end times are ignored.
Sourcepub fn key_eq(&self, other: &Cert) -> bool
pub fn key_eq(&self, other: &Cert) -> bool
Determine if two certificates are equal in subject/context/key
Sourcepub fn should_replace(&self, other: &Cert) -> bool
pub fn should_replace(&self, other: &Cert) -> bool
Determine if the provided certificate should replace this one.