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

Builder for X509 Certificate Requests

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, &signer).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>().unwrap();

Implementations§

source§

impl<'s, S> RequestBuilder<'s, S>

source

pub fn new(subject: Name, req_signer: &'s S) -> Result<Self, Error>

Creates a new certificate request builder

source

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

Add an extension to this certificate request

source

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

Add an attribute to this certificate request

Trait Implementations§

source§

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

§

type Signer = S

The builder’s object signer
§

type Output = CertReq

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 RequestBuilder<'s, S>
where S: RefUnwindSafe,

§

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

§

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

§

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

§

impl<'s, S> UnwindSafe for RequestBuilder<'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.