From b2a851f87c226d31402afe7a7e7e14e8baefe1fd Mon Sep 17 00:00:00 2001 From: Audun Halland Date: Fri, 3 Jan 2025 01:30:40 +0100 Subject: [PATCH] change signature of signed_by to accept &AsRef issuer --- rcgen/src/certificate.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/rcgen/src/certificate.rs b/rcgen/src/certificate.rs index 0c409048..39da5c15 100644 --- a/rcgen/src/certificate.rs +++ b/rcgen/src/certificate.rs @@ -60,6 +60,12 @@ impl From for CertificateDer<'static> { } } +impl AsRef for Certificate { + fn as_ref(&self) -> &CertificateParams { + &self.params + } +} + /// Parameters used for certificate generation #[allow(missing_docs)] #[non_exhaustive] @@ -150,13 +156,13 @@ impl CertificateParams { pub fn signed_by( self, public_key: &impl PublicKeyData, - issuer: &Certificate, + issuer: &impl AsRef, issuer_key: &KeyPair, ) -> Result { 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, }; @@ -843,6 +849,12 @@ impl CertificateParams { } } +impl AsRef 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| {