-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x509-cert: rework the profile of builder
This is now providing a trait to be implemented by the consumer. A number of implementation are available, including ones trying to abide by CABF Baseline Requirements. Fixes #1281
- Loading branch information
Showing
9 changed files
with
952 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//! Certificate profiles | ||
//! | ||
//! Profiles need implement by the [`Profile`] trait. | ||
//! They may then be consumed by a [`builder::CertificateBuilder`]. | ||
//! | ||
//! | ||
//! Multiple profiles are provided and you may select one depending on your use-case: | ||
//! - [`cabf`] implements the Baseline Requirement from the CA Browser Forum as close as it can be | ||
//! done. | ||
//! - [`piv`] implements the specification for the Personal Identity Verification cards. | ||
//! - [`devid`] implements the specification for IEEE 802.1 AR. Certificates for Secure | ||
//! Device Identity. | ||
//! | ||
//! Please follow each sub-module documentation and select a profile that may suit your needs, or | ||
//! you may implement your own profile, if need be. | ||
#[cfg(doc)] | ||
use crate::builder; | ||
|
||
use crate::{builder::Result, certificate::TbsCertificate, ext::Extension, name::Name}; | ||
use alloc::vec; | ||
use spki::SubjectPublicKeyInfoRef; | ||
|
||
pub mod cabf; | ||
pub mod devid; | ||
pub mod piv; | ||
|
||
/// Profile for certificates | ||
pub trait Profile { | ||
/// Issuer to be used for issued certificates | ||
fn get_issuer(&self, subject: &Name) -> Name; | ||
|
||
/// Subject for the certificate to be used. | ||
fn get_subject(&self) -> Name; | ||
|
||
/// X509v3 extensions to be added in the certificates. | ||
fn build_extensions( | ||
&self, | ||
spk: SubjectPublicKeyInfoRef<'_>, | ||
issuer_spk: SubjectPublicKeyInfoRef<'_>, | ||
tbs: &TbsCertificate, | ||
) -> Result<vec::Vec<Extension>>; | ||
} |
Oops, something went wrong.