Skip to content

Commit

Permalink
change signature of signed_by to accept &AsRef<CertificateParams> issuer
Browse files Browse the repository at this point in the history
  • Loading branch information
audunhalland authored and djc committed Jan 4, 2025
1 parent addc408 commit b2a851f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions rcgen/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ impl From<Certificate> for CertificateDer<'static> {
}
}

impl AsRef<CertificateParams> for Certificate {
fn as_ref(&self) -> &CertificateParams {
&self.params
}
}

/// Parameters used for certificate generation
#[allow(missing_docs)]
#[non_exhaustive]
Expand Down Expand Up @@ -150,13 +156,13 @@ impl CertificateParams {
pub fn signed_by(
self,
public_key: &impl PublicKeyData,
issuer: &Certificate,
issuer: &impl AsRef<Self>,
issuer_key: &KeyPair,
) -> Result<Certificate, Error> {
let issuer = Issuer {
distinguished_name: &issuer.params.distinguished_name,
key_identifier_method: &issuer.params.key_identifier_method,
key_usages: &issuer.params.key_usages,
distinguished_name: &issuer.as_ref().distinguished_name,
key_identifier_method: &issuer.as_ref().key_identifier_method,
key_usages: &issuer.as_ref().key_usages,
key_pair: issuer_key,
};

Expand Down Expand Up @@ -843,6 +849,12 @@ impl CertificateParams {
}
}

impl AsRef<CertificateParams> for CertificateParams {
fn as_ref(&self) -> &CertificateParams {
self
}
}

fn write_general_subtrees(writer: DERWriter, tag: u64, general_subtrees: &[GeneralSubtree]) {
writer.write_tagged_implicit(Tag::context(tag), |writer| {
writer.write_sequence(|writer| {
Expand Down

0 comments on commit b2a851f

Please sign in to comment.