Struct x509_cert::builder::CertificateBuilder
source · 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>
impl<'s, S> CertificateBuilder<'s, S>
sourcepub fn new(
profile: Profile,
serial_number: SerialNumber,
validity: Validity,
subject: Name,
subject_public_key_info: SubjectPublicKeyInfoOwned,
cert_signer: &'s S
) -> Result<Self, Error>
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
sourcepub fn add_extension<E: AsExtension>(
&mut self,
extension: &E
) -> Result<(), Error>
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>
impl<'s, S> Builder for CertificateBuilder<'s, S>
§type Output = CertificateInner
type Output = CertificateInner
Type built by this builder
source§fn finalize(&mut self) -> Result<Vec<u8>>
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>
fn assemble(self, signature: BitString) -> Result<Self::Output, Error>
Assemble the final object from signature.
source§fn build<Signature>(self) -> Result<Self::Output, Error>
fn build<Signature>(self) -> Result<Self::Output, Error>
Run the object through the signer and build it.
source§fn build_with_rng<Signature>(
self,
rng: &mut impl CryptoRngCore
) -> Result<Self::Output, Error>
fn build_with_rng<Signature>( self, rng: &mut impl CryptoRngCore ) -> Result<Self::Output, Error>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more