pub struct CertContext(/* private fields */);
Expand description

Wrapper of a winapi certificate, or a PCCERT_CONTEXT.

Implementations§

source§

impl CertContext

source

pub fn new(data: &[u8]) -> Result<CertContext>

Decodes a DER-formatted X509 certificate.

source

pub fn to_der(&self) -> &[u8]

Get certificate in binary DER form

source

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

Certificate subject public key info

source

pub fn from_pem(pem: &str) -> Result<CertContext>

Decodes a PEM-formatted X509 certificate.

source

pub fn to_pem(&self) -> Result<String>

Get certificate as PEM-formatted X509 certificate.

source

pub fn fingerprint(&self, alg: HashAlgorithm) -> Result<Vec<u8>>

Returns a hash of this certificate

source

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

👎Deprecated: please use fingerprint instead

Returns the sha1 hash of this certificate

The sha1 is returned as a 20-byte array representing the bits of the sha1 hash.

source

pub fn sign_hash_algorithms(&self) -> Result<String>

Returns the <SIGNATURE>/<HASH> string representing the certificate signature.

The <SIGNATURE> value identifies the CNG public key algorithm. The <HASH> value identifies the CNG hash algorithm.

Common examples are:

  • RSA/SHA1
  • RSA/SHA256
  • ECDSA/SHA256
source

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

Returns the signature hash.

source

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

Returns the property displayed by the certificate UI. This property allows the user to describe the certificate’s use.

source

pub fn friendly_name(&self) -> Result<String>

Returns a string that contains the display name for the certificate.

source

pub fn set_friendly_name(&self, name: &str) -> Result<()>

Configures the string that contains the display name for this certificate.

source

pub fn is_time_valid(&self) -> Result<bool>

Verifies the time validity of this certificate relative to the system’s current time.

source

pub fn private_key(&self) -> AcquirePrivateKeyOptions<'_>

Returns a builder used to acquire the private key corresponding to this certificate.

source

pub fn delete(self) -> Result<()>

Deletes this certificate from its certificate store.

source

pub fn set_key_prov_info(&self) -> SetKeyProvInfo<'_>

Returns a builder used to set the private key associated with this certificate.

source

pub fn valid_uses(&self) -> Result<ValidUses>

Returns the valid uses for this certificate

source

pub fn cert_store(&self) -> Option<CertStore>

For a remote certificate, returns a certificate store containing any intermediate certificates provided by the remote sender.

Trait Implementations§

source§

impl Clone for CertContext

source§

fn clone(&self) -> CertContext

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for CertContext

source§

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

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

impl Drop for CertContext

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl PartialEq for CertContext

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl RawPointer for CertContext

source§

unsafe fn from_ptr(t: *mut c_void) -> CertContext

Constructs an instance of this type from its handle / pointer. Read more
source§

unsafe fn as_ptr(&self) -> *mut c_void

Get a raw pointer from the underlying handle / pointer. Read more
source§

impl Send for CertContext

source§

impl Sync for CertContext

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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.