Expose certificate serial and issuer
This commit is contained in:
@@ -164,6 +164,8 @@ impl PublicKeyInfo {
|
|||||||
/// Certificates
|
/// Certificates
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Certificate {
|
pub struct Certificate {
|
||||||
|
serial: BigUint,
|
||||||
|
issuer: String,
|
||||||
subject: String,
|
subject: String,
|
||||||
subject_pki: PublicKeyInfo,
|
subject_pki: PublicKeyInfo,
|
||||||
data: Buffer,
|
data: Buffer,
|
||||||
@@ -223,16 +225,30 @@ impl Certificate {
|
|||||||
_ => return Err(Error::InvalidObject),
|
_ => 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 = format!("{}", parsed_cert.tbs_certificate.subject);
|
||||||
let subject_pki = PublicKeyInfo::parse(&parsed_cert.tbs_certificate.subject_pki)?;
|
let subject_pki = PublicKeyInfo::parse(&parsed_cert.tbs_certificate.subject_pki)?;
|
||||||
|
|
||||||
Ok(Certificate {
|
Ok(Certificate {
|
||||||
|
serial,
|
||||||
|
issuer,
|
||||||
subject,
|
subject,
|
||||||
subject_pki,
|
subject_pki,
|
||||||
data: cert,
|
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.
|
/// Returns the SubjectName field of the certificate.
|
||||||
pub fn subject(&self) -> &str {
|
pub fn subject(&self) -> &str {
|
||||||
&self.subject
|
&self.subject
|
||||||
|
|||||||
Reference in New Issue
Block a user