1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use pkix::x509::GenericCertificate;
use pkix::types::HasOid;
use pkix::FromDer;
use sgx_isa::Report;
use super::attestation::{AttestationInlineSgxLocal, reconstruct_sgx_report};
use super::{Error, Result};
pub fn cert_to_sgx_report(cert: &GenericCertificate) -> Result<Report> {
let attestation = cert.tbscert.get_extension(AttestationInlineSgxLocal::oid()).ok_or(Error::MissingAttestation)?;
let attestation = AttestationInlineSgxLocal::from_der(&attestation.value).map_err(|_| Error::InvalidAttestation)?;
reconstruct_sgx_report(&cert.tbscert.subject, &attestation)
}