@@ -243,6 +243,42 @@ pub trait Builder: Sized {
243243 S :: VerifyingKey : EncodePublicKey ;
244244
245245 /// Run the object through the signer and build it.
246+ ///
247+ /// # Notes
248+ ///
249+ /// When using ECDSA signers, the `Signature` parameter will need to be explicit
250+ /// as multiple implementation of [`signature::Signer`] with various signature
251+ /// are available.
252+ ///
253+ /// This would look like:
254+ #[ cfg_attr( feature = "std" , doc = "```no_run" ) ]
255+ #[ cfg_attr( not( feature = "std" ) , doc = "```ignore" ) ]
256+ /// # use rand::rng;
257+ /// # use std::{
258+ /// # str::FromStr,
259+ /// # time::Duration
260+ /// # };
261+ /// # use x509_cert::{
262+ /// # builder::{self, CertificateBuilder, Builder},
263+ /// # name::Name,
264+ /// # serial_number::SerialNumber,
265+ /// # spki::SubjectPublicKeyInfo,
266+ /// # time::Validity
267+ /// # };
268+ /// #
269+ /// # let mut rng = rng();
270+ /// # let signer = p256::ecdsa::SigningKey::random(&mut rng);
271+ /// # let builder = CertificateBuilder::new(
272+ /// # builder::profile::cabf::Root::new(
273+ /// # false,
274+ /// # Name::from_str("CN=World domination corporation").unwrap()
275+ /// # ).unwrap(),
276+ /// # SerialNumber::from(42u32),
277+ /// # Validity::from_now(Duration::new(5, 0)).unwrap(),
278+ /// # SubjectPublicKeyInfo::from_key(signer.verifying_key()).unwrap()
279+ /// # ).unwrap();
280+ /// let certificate = builder.build::<_, ecdsa::der::Signature<_>>(&signer).unwrap();
281+ /// ```
246282 fn build < S , Signature > ( mut self , signer : & S ) -> Result < Self :: Output >
247283 where
248284 S : Signer < Signature > ,
@@ -258,6 +294,45 @@ pub trait Builder: Sized {
258294 }
259295
260296 /// Run the object through the signer and build it.
297+ ///
298+ /// # Notes
299+ ///
300+ /// When using ECDSA signers, the `Signature` parameter will need to be explicit
301+ /// as multiple implementation of [`signature::Signer`] with various signature
302+ /// are available.
303+ ///
304+ /// This would look like:
305+ #[ cfg_attr( feature = "std" , doc = "```no_run" ) ]
306+ #[ cfg_attr( not( feature = "std" ) , doc = "```ignore" ) ]
307+ /// # use rand::rng;
308+ /// # use std::{
309+ /// # str::FromStr,
310+ /// # time::Duration
311+ /// # };
312+ /// # use x509_cert::{
313+ /// # builder::{self, CertificateBuilder, Builder},
314+ /// # name::Name,
315+ /// # serial_number::SerialNumber,
316+ /// # spki::SubjectPublicKeyInfo,
317+ /// # time::Validity
318+ /// # };
319+ /// #
320+ /// # let mut rng = rng();
321+ /// # let signer = p256::ecdsa::SigningKey::random(&mut rng);
322+ /// # let builder = CertificateBuilder::new(
323+ /// # builder::profile::cabf::Root::new(
324+ /// # false,
325+ /// # Name::from_str("CN=World domination corporation").unwrap()
326+ /// # ).unwrap(),
327+ /// # SerialNumber::from(42u32),
328+ /// # Validity::from_now(Duration::new(5, 0)).unwrap(),
329+ /// # SubjectPublicKeyInfo::from_key(signer.verifying_key()).unwrap()
330+ /// # ).unwrap();
331+ /// let certificate = builder.build_with_rng::<_, ecdsa::der::Signature<_>, _>(
332+ /// &signer,
333+ /// &mut rng
334+ /// ).unwrap();
335+ /// ```
261336 fn build_with_rng < S , Signature , R > ( mut self , signer : & S , rng : & mut R ) -> Result < Self :: Output >
262337 where
263338 S : RandomizedSigner < Signature > ,
@@ -351,6 +426,45 @@ pub trait AsyncBuilder: Sized {
351426 S :: VerifyingKey : EncodePublicKey ;
352427
353428 /// Run the object through the signer and build it.
429+ ///
430+ /// # Notes
431+ ///
432+ /// When using ECDSA signers, the `Signature` parameter will need to be explicit
433+ /// as multiple implementation of [`signature::AsyncSigner`] with various signature
434+ /// are available.
435+ ///
436+ /// This would look like:
437+ #[ cfg_attr( feature = "std" , doc = "```no_run" ) ]
438+ #[ cfg_attr( not( feature = "std" ) , doc = "```ignore" ) ]
439+ /// # use rand::rng;
440+ /// # use std::{
441+ /// # str::FromStr,
442+ /// # time::Duration
443+ /// # };
444+ /// # use x509_cert::{
445+ /// # builder::{self, CertificateBuilder, AsyncBuilder},
446+ /// # name::Name,
447+ /// # serial_number::SerialNumber,
448+ /// # spki::SubjectPublicKeyInfo,
449+ /// # time::Validity
450+ /// # };
451+ /// #
452+ /// # async fn build() -> builder::Result<()> {
453+ /// # let mut rng = rng();
454+ /// # let signer = p256::ecdsa::SigningKey::random(&mut rng);
455+ /// # let builder = CertificateBuilder::new(
456+ /// # builder::profile::cabf::Root::new(
457+ /// # false,
458+ /// # Name::from_str("CN=World domination corporation").unwrap()
459+ /// # ).unwrap(),
460+ /// # SerialNumber::from(42u32),
461+ /// # Validity::from_now(Duration::new(5, 0)).unwrap(),
462+ /// # SubjectPublicKeyInfo::from_key(signer.verifying_key()).unwrap()
463+ /// # ).unwrap();
464+ /// let certificate = builder.build_async::<_, ecdsa::der::Signature<_>>(&signer).await?;
465+ /// # Ok(())
466+ /// # }
467+ /// ```
354468 async fn build_async < S , Signature > ( mut self , signer : & S ) -> Result < Self :: Output >
355469 where
356470 S : AsyncSigner < Signature > ,
@@ -366,6 +480,45 @@ pub trait AsyncBuilder: Sized {
366480 }
367481
368482 /// Run the object through the signer and build it.
483+ ///
484+ /// # Notes
485+ ///
486+ /// When using ECDSA signers, the `Signature` parameter will need to be explicit
487+ /// as multiple implementation of [`signature::AsyncSigner`] with various signature
488+ /// are available.
489+ ///
490+ /// This would look like:
491+ #[ cfg_attr( feature = "std" , doc = "```no_run" ) ]
492+ #[ cfg_attr( not( feature = "std" ) , doc = "```ignore" ) ]
493+ /// # use rand::rng;
494+ /// # use std::{
495+ /// # str::FromStr,
496+ /// # time::Duration
497+ /// # };
498+ /// # use x509_cert::{
499+ /// # builder::{self, CertificateBuilder, AsyncBuilder},
500+ /// # name::Name,
501+ /// # serial_number::SerialNumber,
502+ /// # spki::SubjectPublicKeyInfo,
503+ /// # time::Validity
504+ /// # };
505+ /// #
506+ /// # async fn build() -> builder::Result<()> {
507+ /// # let mut rng = rng();
508+ /// # let signer = p256::ecdsa::SigningKey::random(&mut rng);
509+ /// # let builder = CertificateBuilder::new(
510+ /// # builder::profile::cabf::Root::new(
511+ /// # false,
512+ /// # Name::from_str("CN=World domination corporation").unwrap()
513+ /// # ).unwrap(),
514+ /// # SerialNumber::from(42u32),
515+ /// # Validity::from_now(Duration::new(5, 0)).unwrap(),
516+ /// # SubjectPublicKeyInfo::from_key(signer.verifying_key()).unwrap()
517+ /// # ).unwrap();
518+ /// let certificate = builder.build_with_rng_async::<_, ecdsa::der::Signature<_>, _>(&signer, &mut rng).await?;
519+ /// # Ok(())
520+ /// # }
521+ /// ```
369522 async fn build_with_rng_async < S , Signature , R > (
370523 mut self ,
371524 signer : & S ,
0 commit comments