pub struct OcspRequestBuilder { /* private fields */ }Available on crate feature
builder only.Expand description
X509 OCSP Request builder
use der::Decode;
use sha1::Sha1;
use x509_cert::{serial_number::SerialNumber, Certificate};
use x509_ocsp::builder::OcspRequestBuilder;
use x509_ocsp::{ext::Nonce, Request};
let issuer = Certificate::from_der(ISSUER_DER).unwrap();
let cert = Certificate::from_der(CERT_DER).unwrap();
let req = OcspRequestBuilder::default()
.with_request(Request::from_cert::<Sha1>(&issuer, &cert).unwrap())
.build();
let mut rng = rand::thread_rng();
let req = OcspRequestBuilder::default()
.with_request(Request::from_issuer::<Sha1>(&issuer, SerialNumber::from(2usize)).unwrap())
.with_request(Request::from_issuer::<Sha1>(&issuer, SerialNumber::from(3usize)).unwrap())
.with_request(Request::from_issuer::<Sha1>(&issuer, SerialNumber::from(4usize)).unwrap())
.with_extension(Nonce::generate(&mut rng, 32).unwrap())
.unwrap()
.build();
let mut signer = rsa_signer();
let signer_cert_chain = vec![cert.clone()];
let req = OcspRequestBuilder::default()
.with_request(Request::from_cert::<Sha1>(&issuer, &cert).unwrap())
.with_extension(Nonce::generate(&mut rng, 32).unwrap())
.unwrap()
.sign(&mut signer, Some(signer_cert_chain))
.unwrap();Implementations§
Source§impl OcspRequestBuilder
impl OcspRequestBuilder
Sourcepub fn with_requestor_name(self, requestor_name: GeneralName) -> Self
pub fn with_requestor_name(self, requestor_name: GeneralName) -> Self
Sets the requestor name as specified in RFC 6960 Section 4.1.1
Sourcepub fn with_request(self, request: Request) -> Self
pub fn with_request(self, request: Request) -> Self
Adds a Request to the builder as defined in RFC 6960 Section 4.1.1.
Sourcepub fn with_extension(self, ext: impl AsExtension) -> Result<Self, Error>
pub fn with_extension(self, ext: impl AsExtension) -> Result<Self, Error>
Adds a request extension as specified in RFC 6960 Section 4.4. Errors when the extension encoding fails.
Sourcepub fn build(self) -> OcspRequest
pub fn build(self) -> OcspRequest
Consumes the builder and returns an OcspRequest
Sourcepub fn sign<S, Sig>(
self,
signer: &mut S,
certificate_chain: Option<Vec<Certificate>>,
) -> Result<OcspRequest, Error>
pub fn sign<S, Sig>( self, signer: &mut S, certificate_chain: Option<Vec<Certificate>>, ) -> Result<OcspRequest, Error>
Consumes the builder and returns a signed OcspRequest. Errors when the algorithm
identifier encoding, message encoding, or signature generation fails.
Sourcepub fn sign_with_rng<S, Sig>(
self,
signer: &mut S,
rng: &mut impl CryptoRngCore,
certificate_chain: Option<Vec<Certificate>>,
) -> Result<OcspRequest, Error>
pub fn sign_with_rng<S, Sig>( self, signer: &mut S, rng: &mut impl CryptoRngCore, certificate_chain: Option<Vec<Certificate>>, ) -> Result<OcspRequest, Error>
Consumes the builder and returns a signed OcspRequest. Errors when the algorithm
identifier encoding, message encoding, or signature generation fails.
Trait Implementations§
Source§impl Clone for OcspRequestBuilder
impl Clone for OcspRequestBuilder
Source§fn clone(&self) -> OcspRequestBuilder
fn clone(&self) -> OcspRequestBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OcspRequestBuilder
impl Debug for OcspRequestBuilder
Source§impl Default for OcspRequestBuilder
impl Default for OcspRequestBuilder
Source§fn default() -> OcspRequestBuilder
fn default() -> OcspRequestBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OcspRequestBuilder
impl RefUnwindSafe for OcspRequestBuilder
impl Send for OcspRequestBuilder
impl Sync for OcspRequestBuilder
impl Unpin for OcspRequestBuilder
impl UnwindSafe for OcspRequestBuilder
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