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

CertificateRequestBuilder

Struct CertificateRequestBuilder 

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

Builder for X509 Certificate Requests (CSR)

use x509_cert::{
    builder::{Builder, RequestBuilder},
    ext::pkix::{name::GeneralName, SubjectAltName},
    name::Name,
};
use std::str::FromStr;

use std::net::{IpAddr, Ipv4Addr};
let subject = Name::from_str("CN=service.domination.world").unwrap();

let signer = ecdsa_signer();
let mut builder = RequestBuilder::new(subject).expect("Create certificate request");
builder
    .add_extension(&SubjectAltName(vec![GeneralName::from(IpAddr::V4(
        Ipv4Addr::new(192, 0, 2, 0),
    ))]))
    .unwrap();

let cert_req = builder.build::<_, DerSignature>(&signer).unwrap();

Implementations§

Source§

impl RequestBuilder

Source

pub fn new(subject: Name) -> Result<RequestBuilder, Error>

Creates a new certificate request 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 request

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

Source

pub fn add_attribute<A>(&mut self, attribute: &A) -> Result<(), Error>
where A: AsAttribute,

Add an attribute to this certificate request

Trait Implementations§

Source§

impl Builder for RequestBuilder

Source§

type Output = CertReq

Type built by this builder
Source§

fn finalize<S>(&mut self, 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<<RequestBuilder 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§

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