pub struct Certificate(/* private fields */);Expand description
Parsed X.509 certificate. Cheap to clone (Arc), Send + Sync.
Implementations§
Source§impl Certificate
impl Certificate
Sourcepub fn from_der(der: impl Into<Bytes>) -> Result<Certificate, Error>
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.
Sourcepub fn from_pem(pem: &[u8]) -> Result<Certificate, Error>
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.
Sourcepub fn from_pem_multi(pem: &[u8]) -> Result<Vec<Certificate>, Error>
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.
Sourcepub fn public_key_der(&self) -> &[u8] ⓘ
pub fn public_key_der(&self) -> &[u8] ⓘ
DER encoded SubjectPublicKeyInfo.
Sourcepub fn serial_hex(&self) -> &str
pub fn serial_hex(&self) -> &str
Serial number, uppercase hex without leading zero bytes (OpenSSL BN_bn2hex style).
Sourcepub fn subject_der(&self) -> &[u8] ⓘ
pub fn subject_der(&self) -> &[u8] ⓘ
DER encoded subject name.
Sourcepub fn issuer_der(&self) -> &[u8] ⓘ
pub fn issuer_der(&self) -> &[u8] ⓘ
DER encoded issuer name.
Sourcepub fn is_self_issued(&self) -> bool
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.
Sourcepub fn key_type(&self) -> Option<KeyType>
pub fn key_type(&self) -> Option<KeyType>
Public key type, None for unsupported key types or curves.
Sourcepub fn subject_cn(&self) -> Option<&str>
pub fn subject_cn(&self) -> Option<&str>
First subject commonName, as encoded (no case folding).
Sourcepub fn san(&self) -> &SubjectAltNames
pub fn san(&self) -> &SubjectAltNames
Subject alternative names.
Sourcepub fn not_before(&self) -> SystemTime
pub fn not_before(&self) -> SystemTime
Start of the validity period.
Sourcepub fn not_after(&self) -> SystemTime
pub fn not_after(&self) -> SystemTime
End of the validity period.
Sourcepub fn digest(&self, alg: Algorithm) -> &[u8] ⓘ
pub fn digest(&self, alg: Algorithm) -> &[u8] ⓘ
Digest of the DER encoding (computed once per algorithm).
Sourcepub fn thumbprint(&self, alg: Algorithm) -> String
pub fn thumbprint(&self, alg: Algorithm) -> String
Thumbprint as lowercase hex.
Trait Implementations§
Source§impl Clone for Certificate
impl Clone for Certificate
Source§fn clone(&self) -> Certificate
fn clone(&self) -> Certificate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Certificate
impl Debug for Certificate
impl Eq for Certificate
Auto Trait Implementations§
impl Freeze for Certificate
impl RefUnwindSafe for Certificate
impl Send for Certificate
impl Sync for Certificate
impl Unpin for Certificate
impl UnsafeUnpin for Certificate
impl UnwindSafe for Certificate
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.