From 5e8a014be2266d3f3c9d4456456da25670ff64c5 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 15 Dec 2019 10:35:22 +0000 Subject: [PATCH] Expose certificate serial and issuer --- src/certificate.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/certificate.rs b/src/certificate.rs index 674f010..e13bb89 100644 --- a/src/certificate.rs +++ b/src/certificate.rs @@ -164,6 +164,8 @@ impl PublicKeyInfo { /// Certificates #[derive(Clone, Debug)] pub struct Certificate { + serial: BigUint, + issuer: String, subject: String, subject_pki: PublicKeyInfo, data: Buffer, @@ -223,16 +225,30 @@ impl Certificate { _ => return Err(Error::InvalidObject), }; + let serial = parsed_cert.tbs_certificate.serial; + let issuer = format!("{}", parsed_cert.tbs_certificate.issuer); let subject = format!("{}", parsed_cert.tbs_certificate.subject); let subject_pki = PublicKeyInfo::parse(&parsed_cert.tbs_certificate.subject_pki)?; Ok(Certificate { + serial, + issuer, subject, subject_pki, data: cert, }) } + /// Returns the serial number of the certificate. + pub fn serial(&self) -> &BigUint { + &self.serial + } + + /// Returns the Issuer field of the certificate. + pub fn issuer(&self) -> &str { + &self.subject + } + /// Returns the SubjectName field of the certificate. pub fn subject(&self) -> &str { &self.subject