Struct edcert::certificate::Certificate [] [src]

pub struct Certificate {
    // some fields omitted
}

Methods

impl Certificate

fn generate_random(meta: Meta, expires: DateTime<UTC>) -> Certificate

This method generates a random public/private keypair and a certificate for it.

fn get_meta_mut(&mut self) -> &mut Meta

This method returns a mutable reference to the meta structure.

fn get_meta(&self) -> &Meta

This method returns a reference to the meta structure.

fn get_public_key(&self) -> &Vec<u8>

This method returns a reference to the public key.

fn get_private_key<'a>(&'a self) -> Option<&'a Vec<u8>>

This method returns the private key, if it is known, or None if the certificate has been initialized without the private key.

fn has_private_key(&self) -> bool

This method returns true, if the private key is saved in the certificate.

fn get_expires(&self) -> &str

This method returns the expiration date as a RFC 3339 string.

fn set_private_key(&mut self, private_key: Vec<u8>)

This method replaces the current private key of this certificate with the given one.

fn is_expired(&self) -> bool

This method checks, if this certificates expiration date is now or in the past.

fn safehash(&self) -> [u8; CERTIFICATE_BYTE_LEN]

This method returns a "hash". This is used to validate the certificate. All relevant information of the certificate is used to produce the hash, including the public key, meta data and the expiration date.

fn get_parent(&self) -> Option<&Certificate>

This method returns the parent certificate of this certificate, if it exists.

fn is_signed(&self) -> bool

This method returns true, if a signature exists (is not None). This doesn't validate the signature.

fn sign(&self, data: &[u8]) -> Option<Vec<u8>>

This method signs the given data and returns the signature.

fn sign_with_master(&mut self, master_private_key: &[u8])

This method signs this certificate with the given private master key.

fn sign_certificate(&self, other: &mut Certificate) -> Result<(), &'static str>

This method signs another certificate with the private key of this certificate.

fn is_valid(&self, master_pk: &[u8]) -> Result<(), &'static str>

This method verifies that this certificate is valid by analyzing the trust chain.

fn verify(&self, data: &[u8], signature: &[u8]) -> bool

This method verifies that the given signature is valid for the given data.

fn is_revoked(&self, revokeserver: &str) -> Result<(), &'static str>

fn from_json(compressed: &[u8]) -> Result<Certificate, &'static str>

takes a json-encoded byte vector and tries to create a certificate from it.

fn to_json(&self) -> Vec<u8>

Converts this certificate in a json-encoded byte vector.

fn save(&self, folder: &str)

Saves this certificate into a folder: one file for the certificate and one file for the private key.

fn load_from_file(filename: &str) -> Result<Certificate, &'static str>

This method loads a certificate from a file.

fn load_private_key(&mut self, filename: &str) -> Result<(), &'static str>

This method reads a private key from a file and sets it in this certificate.

Trait Implementations

Derived Implementations

impl Debug for Certificate

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl Encodable for Certificate

fn encode<__S: Encoder>(&self, __arg_0: &mut __S) -> Result<(), __S::Error>

impl Decodable for Certificate

fn decode<__D: Decoder>(__arg_0: &mut __D) -> Result<Certificate, __D::Error>

impl Clone for Certificate

fn clone(&self) -> Certificate

fn clone_from(&mut self, source: &Self)