Skip to main content
This is unreleased documentation for the main (development) branch of crypto-glue.

CertificateBuilder

Struct CertificateBuilder 

Source
pub struct CertificateBuilder<P> { /* private fields */ }
Expand description

X509 Certificate builder

use der::Decode;
use x509_cert::spki::SubjectPublicKeyInfo;
use x509_cert::builder::{CertificateBuilder, Builder, 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 subject = Name::from_str("CN=World domination corporation,O=World domination Inc,C=US").unwrap();
let profile = profile::cabf::Root::new(false,subject).expect("Create root profile");

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

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

let cert = builder.build(&signer).expect("Create certificate");

Implementations§

Source§

impl<P> CertificateBuilder<P>
where P: BuilderProfile,

Source

pub fn new( profile: P, serial_number: SerialNumber, validity: Validity, subject_public_key_info: SubjectPublicKeyInfo<Any, BitString>, ) -> Result<CertificateBuilder<P>, Error>

Creates a new certificate builder

Source

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

Add an extension to this certificate

Extensions need to implement ToExtension, examples may be found in in ToExtension documentation or the implementors.

Trait Implementations§

Source§

impl<P> Builder for CertificateBuilder<P>
where P: BuilderProfile,

Source§

type Output = CertificateInner

Type built by this builder
Source§

fn finalize<S>(&mut self, cert_signer: &S) -> Result<Vec<u8>, Error>

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

fn assemble<S>( self, signature: BitString, _signer: &S, ) -> Result<<CertificateBuilder<P> as Builder>::Output, Error>

Assemble the final object from signature.
Source§

fn build<S, Signature>(self, signer: &S) -> Result<Self::Output, Error>

Run the object through the signer and build it. Read more
Source§

fn build_with_rng<S, Signature, R>( self, signer: &S, rng: &mut R, ) -> Result<Self::Output, Error>

Run the object through the signer and build it. Read more

Auto Trait Implementations§

§

impl<P> Freeze for CertificateBuilder<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for CertificateBuilder<P>
where P: RefUnwindSafe,

§

impl<P> Send for CertificateBuilder<P>
where P: Send,

§

impl<P> Sync for CertificateBuilder<P>
where P: Sync,

§

impl<P> Unpin for CertificateBuilder<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for CertificateBuilder<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for CertificateBuilder<P>
where P: UnwindSafe,

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> AsyncBuilder for T
where T: Builder,

Source§

type Output = <T as Builder>::Output

Type built by this builder
Source§

fn assemble<S>( self, signature: BitString, signer: &S, ) -> Result<<T as AsyncBuilder>::Output, Error>

Assemble the final object from signature.
Source§

fn finalize<S>(&mut self, signer: &S) -> Result<Vec<u8>, Error>

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

async fn build_async<S, Signature>( self, signer: &S, ) -> Result<Self::Output, Error>

Run the object through the signer and build it. Read more
Source§

async fn build_with_rng_async<S, Signature, R>( self, signer: &S, rng: &mut R, ) -> Result<Self::Output, Error>

Run the object through the signer and build it. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more