From ed8daeb097d1552e0306f8a9989f5a9c878e6ba7 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 10 Sep 2024 11:09:29 -0700 Subject: [PATCH] x509-cert: rename `builder::BuildProfile` to avoid confusion (#1514) --- x509-cert/src/builder.rs | 12 +++++++++--- x509-cert/src/builder/profile.rs | 9 +++++++-- x509-cert/src/builder/profile/cabf.rs | 4 ++-- x509-cert/src/builder/profile/cabf/tls.rs | 6 +++--- x509-cert/src/builder/profile/devid.rs | 4 ++-- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/x509-cert/src/builder.rs b/x509-cert/src/builder.rs index 6e0b5370f..8ca55c014 100644 --- a/x509-cert/src/builder.rs +++ b/x509-cert/src/builder.rs @@ -21,7 +21,13 @@ use crate::{ pub mod profile; -use self::profile::Profile; +use self::profile::BuildProfile; + +#[deprecated( + since = "0.3.0", + note = "please use `x509_cert::builder::profile::BuildProfile` instead" +)] +pub use self::profile::BuildProfile as Profile; const NULL_OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("0.0.0"); @@ -146,7 +152,7 @@ pub struct CertificateBuilder

{ impl

CertificateBuilder

where - P: Profile, + P: BuildProfile, { /// Creates a new certificate builder pub fn new( @@ -346,7 +352,7 @@ pub trait Builder: Sized { impl

Builder for CertificateBuilder

where - P: Profile, + P: BuildProfile, { type Output = Certificate; diff --git a/x509-cert/src/builder/profile.rs b/x509-cert/src/builder/profile.rs index 6f2e88f8d..cb7090051 100644 --- a/x509-cert/src/builder/profile.rs +++ b/x509-cert/src/builder/profile.rs @@ -1,6 +1,6 @@ //! Certificate profiles //! -//! Profiles need implement by the [`Profile`] trait. +//! Profiles need implement by the [`BuildProfile`] trait. //! They may then be consumed by a [`builder::CertificateBuilder`]. //! //! @@ -24,7 +24,12 @@ pub mod cabf; pub mod devid; /// Profile for certificates -pub trait Profile { +/// +/// The profile will define the various extensions to add to a certificate, this may be used to +/// generate a [`cabf::Root`], or a TLS [`cabf::tls::Subscriber`] certificate. +/// +/// See [implementors](#implementors) for a full list of existing profiles. +pub trait BuildProfile { /// Issuer to be used for issued certificates fn get_issuer(&self, subject: &Name) -> Name; diff --git a/x509-cert/src/builder/profile/cabf.rs b/x509-cert/src/builder/profile/cabf.rs index f3691e15f..f69ed4722 100644 --- a/x509-cert/src/builder/profile/cabf.rs +++ b/x509-cert/src/builder/profile/cabf.rs @@ -5,7 +5,7 @@ use alloc::vec; use std::collections::HashSet; use crate::{ - builder::{Error, Profile, Result}, + builder::{BuildProfile, Error, Result}, certificate::TbsCertificate, ext::{ pkix::{ @@ -123,7 +123,7 @@ impl Root { } } -impl Profile for Root { +impl BuildProfile for Root { fn get_issuer(&self, subject: &Name) -> Name { subject.clone() } diff --git a/x509-cert/src/builder/profile/cabf/tls.rs b/x509-cert/src/builder/profile/cabf/tls.rs index 32253cb56..fa47de3df 100644 --- a/x509-cert/src/builder/profile/cabf/tls.rs +++ b/x509-cert/src/builder/profile/cabf/tls.rs @@ -13,7 +13,7 @@ use const_oid::db::rfc5912; use crate::{ attr::AttributeTypeAndValue, - builder::{Profile, Result}, + builder::{BuildProfile, Result}, certificate::TbsCertificate, ext::{ pkix::{ @@ -50,7 +50,7 @@ pub struct Subordinate { pub client_auth: bool, } -impl Profile for Subordinate { +impl BuildProfile for Subordinate { fn get_issuer(&self, _subject: &Name) -> Name { self.issuer.clone() } @@ -231,7 +231,7 @@ pub struct Tls12Options { pub enable_key_agreement: bool, } -impl Profile for Subscriber { +impl BuildProfile for Subscriber { fn get_issuer(&self, _subject: &Name) -> Name { self.issuer.clone() } diff --git a/x509-cert/src/builder/profile/devid.rs b/x509-cert/src/builder/profile/devid.rs index 9717d88f6..7ffc50a39 100644 --- a/x509-cert/src/builder/profile/devid.rs +++ b/x509-cert/src/builder/profile/devid.rs @@ -16,7 +16,7 @@ use alloc::vec; use crate::{ - builder::{Profile, Result}, + builder::{BuildProfile, Result}, certificate::TbsCertificate, ext::{ pkix::{ @@ -112,7 +112,7 @@ impl DevId { } } -impl Profile for DevId { +impl BuildProfile for DevId { fn get_issuer(&self, _subject: &Name) -> Name { self.issuer.clone() }