Pkcs12

Struct Pkcs12 

Source
pub struct Pkcs12 { /* private fields */ }
Expand description

A PKCS#12 / PFX bundle (PKCS12*).

Load from DER with Pkcs12::from_der or create with Pkcs12::create.

Implementations§

Source§

impl Pkcs12

Source

pub fn new() -> Result<Self, ErrorStack>

Allocate a new, empty PKCS12 structure.

Returns an initialised-but-empty bundle. Use this when building a PKCS#12 structure field-by-field via the raw OpenSSL API. For the common case of creating a complete bundle from a key and certificate, prefer Pkcs12::create.

§Errors

Returns Err if OpenSSL cannot allocate the structure.

Source

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

Load a PKCS#12 bundle from DER-encoded bytes.

§Errors
Source

pub fn to_der(&self) -> Result<Vec<u8>, ErrorStack>

Serialise the bundle to DER.

§Errors
Source

pub fn parse( &self, password: &str, ) -> Result<(Pkey<Private>, X509, Vec<X509>), ErrorStack>

Parse the bundle, returning the private key, end-entity certificate, and any additional CA certificates.

password is the MAC / encryption password. Pass "" for an unencrypted bundle.

§Errors
Source

pub fn create( password: &str, name: &str, key: &Pkey<Private>, cert: &X509, ca: &[X509], ) -> Result<Self, ErrorStack>

Create a PKCS#12 bundle from a private key and certificate.

  • password: MAC / encryption passphrase.
  • name: Friendly name stored in the bundle (e.g. the subject CN).
  • ca: Optional slice of additional CA certificates.

Uses AES-256-CBC for key encryption and SHA-256 for the MAC (nid_key = 0, nid_cert = 0 → OpenSSL defaults).

§Errors

Trait Implementations§

Source§

impl Drop for Pkcs12

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Pkcs12

Source§

impl Sync for Pkcs12

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.