Skip to main content

Certificate

Struct Certificate 

Source
pub struct Certificate(/* private fields */);
Expand description

Parsed X.509 certificate. Cheap to clone (Arc), Send + Sync.

Implementations§

Source§

impl Certificate

Source

pub fn from_der(der: impl Into<Bytes>) -> Result<Certificate, Error>

Parses a DER encoded certificate, taking ownership of the buffer (no copy).

Trailing data after the certificate is ignored (and dropped from Self::der).

§Errors

Error::InvalidDer if the data is not a valid X.509 certificate, its version is unsupported, or its validity dates cannot be represented by SystemTime.

Source

pub fn from_pem(pem: &[u8]) -> Result<Certificate, Error>

Parses the first CERTIFICATE (or X509 CERTIFICATE) block of a PEM document.

§Errors

Error::InvalidPem if no certificate block is found or base64 is invalid, Error::InvalidDer if the decoded block is not a valid certificate.

Source

pub fn from_pem_multi(pem: &[u8]) -> Result<Vec<Certificate>, Error>

Parses all CERTIFICATE blocks of a PEM document, in order.

§Errors

See Self::from_pem. An empty document returns an empty list.

Source

pub fn der(&self) -> &Bytes ⓘ

DER encoding.

Source

pub fn public_key_der(&self) -> &[u8] ⓘ

DER encoded SubjectPublicKeyInfo.

Source

pub fn version(&self) -> u32

X.509 version (1, 2 or 3).

Source

pub fn serial_hex(&self) -> &str

Serial number, uppercase hex without leading zero bytes (OpenSSL BN_bn2hex style).

Source

pub fn subject(&self) -> &str

Subject distinguished name (RFC 4514 style), for logging.

Source

pub fn issuer(&self) -> &str

Issuer distinguished name (RFC 4514 style), for logging.

Source

pub fn subject_der(&self) -> &[u8] ⓘ

DER encoded subject name.

Source

pub fn issuer_der(&self) -> &[u8] ⓘ

DER encoded issuer name.

Source

pub fn is_self_issued(&self) -> bool

Whether subject and issuer names are equal (byte comparison of the DER names); the signature is not checked.

Source

pub fn key_type(&self) -> Option<KeyType>

Public key type, None for unsupported key types or curves.

Source

pub fn subject_cn(&self) -> Option<&str>

First subject commonName, as encoded (no case folding).

Source

pub fn san(&self) -> &SubjectAltNames

Subject alternative names.

Source

pub fn not_before(&self) -> SystemTime

Start of the validity period.

Source

pub fn not_after(&self) -> SystemTime

End of the validity period.

Source

pub fn sha1(&self) -> &[u8; 20]

SHA-1 digest of the DER encoding (computed once).

Source

pub fn sha256(&self) -> &[u8; 32]

SHA-256 digest of the DER encoding (computed once).

Source

pub fn digest(&self, alg: Algorithm) -> &[u8] ⓘ

Digest of the DER encoding (computed once per algorithm).

Source

pub fn thumbprint(&self, alg: Algorithm) -> String

Thumbprint as lowercase hex.

Source

pub fn to_pem(&self) -> String

PEM encoding (CERTIFICATE label, 64 column lines, trailing newline).

Trait Implementations§

Source§

impl Clone for Certificate

Source§

fn clone(&self) -> Certificate

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Certificate

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Certificate

Source§

impl PartialEq for Certificate

Source§

fn eq(&self, other: &Certificate) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. 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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V