Struct RequestBuilder

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

Source§

type Signer = S

The builder’s object signer
Source§

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> Freeze for RequestBuilder<'s, S>

§

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

Source§

type Output = T

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