Skip to main content

Certificate

Struct Certificate 

Source
pub struct Certificate { /* private fields */ }

Implementations§

Source§

impl Certificate

Source

pub fn from_der(der: &[u8]) -> Result<Self>

Examples found in repository?
examples/03_certificate_inspect.rs (line 7)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
8    println!(
9        "subject={:?} emails={:?} serial_len={}",
10        certificate.subject_summary()?,
11        certificate.email_addresses()?,
12        certificate.serial_number()?.len()
13    );
14    Ok(())
15}
More examples
Hide additional examples
examples/11_cms_cert_bag.rs (line 7)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
8    let encoded = Cms::encode_supporting_certificates(&[certificate])?;
9    let decoded = Cms::decode_all_certificates(&encoded)?;
10    println!("cms_len={} certs={}", encoded.len(), decoded.len());
11    Ok(())
12}
examples/05_trust_evaluate.rs (line 7)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
8    let policy = Policy::basic_x509()?;
9    let mut trust = Trust::new(&certificate, &[policy])?;
10    trust.set_anchor_certificates(&[certificate])?;
11    trust.set_anchor_certificates_only(true)?;
12    trust.set_network_fetch_allowed(false)?;
13    trust.evaluate()?;
14    println!("chain_len={}", trust.certificate_chain()?.len());
15    Ok(())
16}
Source

pub fn from_pem(pem: &[u8]) -> Result<Self>

Source

pub fn subject_summary(&self) -> Result<Option<String>>

Examples found in repository?
examples/03_certificate_inspect.rs (line 10)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
8    println!(
9        "subject={:?} emails={:?} serial_len={}",
10        certificate.subject_summary()?,
11        certificate.email_addresses()?,
12        certificate.serial_number()?.len()
13    );
14    Ok(())
15}
More examples
Hide additional examples
examples/02_identity_pkcs12.rs (line 13)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let identity = Identity::import_pkcs12_first(&support::fixture("test-identity.p12"), "password")?;
8    let certificate = identity.certificate()?;
9    println!(
10        "label={:?} chain_count={} subject={:?}",
11        identity.label()?,
12        identity.chain_count(),
13        certificate.subject_summary()?
14    );
15    Ok(())
16}
Source

pub fn common_name(&self) -> Result<Option<String>>

Source

pub fn email_addresses(&self) -> Result<Vec<String>>

Examples found in repository?
examples/03_certificate_inspect.rs (line 11)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
8    println!(
9        "subject={:?} emails={:?} serial_len={}",
10        certificate.subject_summary()?,
11        certificate.email_addresses()?,
12        certificate.serial_number()?.len()
13    );
14    Ok(())
15}
Source

pub fn normalized_subject_sequence(&self) -> Result<Vec<u8>>

Source

pub fn normalized_issuer_sequence(&self) -> Result<Vec<u8>>

Source

pub fn serial_number(&self) -> Result<Vec<u8>>

Examples found in repository?
examples/03_certificate_inspect.rs (line 12)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
8    println!(
9        "subject={:?} emails={:?} serial_len={}",
10        certificate.subject_summary()?,
11        certificate.email_addresses()?,
12        certificate.serial_number()?.len()
13    );
14    Ok(())
15}
Source

pub fn not_valid_before(&self) -> Result<Option<SystemTime>>

Source

pub fn not_valid_after(&self) -> Result<Option<SystemTime>>

Source

pub fn der_data(&self) -> Result<Vec<u8>>

Source

pub fn public_key(&self) -> Result<PublicKey>

Trait Implementations§

Source§

impl Debug for Certificate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.