pub struct CertificateBuilder<'s, S> { /* private fields */ }
Available on crate feature builder only.
Expand description

X509 Certificate builder

use der::Decode;
use x509_cert::spki::SubjectPublicKeyInfoOwned;
use x509_cert::builder::{CertificateBuilder, Profile};
use x509_cert::name::Name;
use x509_cert::serial_number::SerialNumber;
use x509_cert::time::Validity;
use std::str::FromStr;


let serial_number = SerialNumber::from(42u32);
let validity = Validity::from_now(Duration::new(5, 0)).unwrap();
let profile = Profile::Root;
let subject = Name::from_str("CN=World domination corporation,O=World domination Inc,C=US").unwrap();

let pub_key = SubjectPublicKeyInfoOwned::try_from(RSA_2048_DER).expect("get rsa pub key");

let mut signer = rsa_signer();
let mut builder = CertificateBuilder::new(
    profile,
    serial_number,
    validity,
    subject,
    pub_key,
    &signer,
)
.expect("Create certificate");

Implementations§

source§

impl<'s, S> CertificateBuilder<'s, S>

source

pub fn new( profile: Profile, serial_number: SerialNumber, validity: Validity, subject: Name, subject_public_key_info: SubjectPublicKeyInfoOwned, cert_signer: &'s S ) -> Result<Self, Error>

Creates a new certificate builder

source

pub fn add_extension<E: AsExtension>( &mut self, extension: &E ) -> Result<(), Error>

Add an extension to this certificate

Trait Implementations§

source§

impl<'s, S> Builder for CertificateBuilder<'s, S>

§

type Signer = S

The builder’s object signer
§

type Output = CertificateInner

Type built by this builder
source§

fn signer(&self) -> &Self::Signer

Return a reference to the signer.
source§

fn finalize(&mut self) -> Result<Vec<u8>>

Finalize and return a serialization of the object for signature.
source§

fn assemble(self, signature: BitString) -> Result<Self::Output, Error>

Assemble the final object from signature.
source§

fn build<Signature>(self) -> Result<Self::Output, Error>
where Self::Signer: Signer<Signature>, Signature: SignatureBitStringEncoding,

Run the object through the signer and build it.
source§

fn build_with_rng<Signature>( self, rng: &mut impl CryptoRngCore ) -> Result<Self::Output, Error>
where Self::Signer: RandomizedSigner<Signature>, Signature: SignatureBitStringEncoding,

Run the object through the signer and build it.

Auto Trait Implementations§

§

impl<'s, S> RefUnwindSafe for CertificateBuilder<'s, S>
where S: RefUnwindSafe,

§

impl<'s, S> Send for CertificateBuilder<'s, S>
where S: Sync,

§

impl<'s, S> Sync for CertificateBuilder<'s, S>
where S: Sync,

§

impl<'s, S> Unpin for CertificateBuilder<'s, S>

§

impl<'s, S> UnwindSafe for CertificateBuilder<'s, S>
where S: RefUnwindSafe,

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> Same for T

§

type Output = T

Should always be Self
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.