Struct Certificate

pub struct Certificate { /* private fields */ }

Represents a server X509 certificate.

Implementations

impl Certificate

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

Create a Certificate from a binary DER encoded certificate

Examples

# use std::fs::File;
# use std::io::Read;
# fn cert() -> Result<(), Box<dyn std::error::Error>> {
let mut buf = Vec::new();
File::open("my_cert.der")?
    .read_to_end(&mut buf)?;
let cert = reqwest::Certificate::from_der(&buf)?;
# drop(cert);
# Ok(())
# }
fn from_pem(pem: &[u8]) -> Result<Certificate>

Create a Certificate from a PEM encoded certificate

Examples

# use std::fs::File;
# use std::io::Read;
# fn cert() -> Result<(), Box<dyn std::error::Error>> {
let mut buf = Vec::new();
File::open("my_cert.pem")?
    .read_to_end(&mut buf)?;
let cert = reqwest::Certificate::from_pem(&buf)?;
# drop(cert);
# Ok(())
# }
fn from_pem_bundle(pem_bundle: &[u8]) -> Result<Vec<Certificate>>

Create a collection of Certificates from a PEM encoded certificate bundle. Example byte sources may be .crt, .cer or .pem files.

Examples

# use std::fs::File;
# use std::io::Read;
# fn cert() -> Result<(), Box<dyn std::error::Error>> {
let mut buf = Vec::new();
File::open("ca-bundle.crt")?
    .read_to_end(&mut buf)?;
let certs = reqwest::Certificate::from_pem_bundle(&buf)?;
# drop(certs);
# Ok(())
# }

Trait Implementations

impl Clone for Certificate

fn clone(&self) -> Certificate

impl Debug for Certificate

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

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<T> Any for Certificate where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for Certificate

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Instrument for Certificate

impl<T> PolicyExt for Certificate where T: ?Sized,

fn and<P, B, E>(self, other: P) -> And<T, P>
where
    T: Sized + Policy<B, E>,
    P: Policy<B, E>,
fn or<P, B, E>(self, other: P) -> Or<T, P>
where
    T: Sized + Policy<B, E>,
    P: Policy<B, E>,

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> WithSubscriber for Certificate

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

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, U> TryFrom<U> for Certificate where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

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