Skip to content

Commit 0059071

Browse files
committed
OK
Signed-off-by: Jun Kimura <jun.kimura@datachain.jp>
1 parent 5ffea4f commit 0059071

File tree

1 file changed

+18
-20
lines changed
  • modules/remote-attestation/src

1 file changed

+18
-20
lines changed

modules/remote-attestation/src/dcap.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ use dcap_rs::types::quotes::version_3::QuoteV3;
66
use dcap_rs::utils::cert::{extract_sgx_extension, parse_certchain, parse_pem};
77
use keymanager::EnclaveKeyManager;
88
use lcp_types::Time;
9+
use log::*;
910
use sgx_types::{sgx_qe_get_quote, sgx_qe_get_quote_size, sgx_quote3_error_t, sgx_report_t};
1011

1112
const INTEL_ROOT_CA: &'static [u8] =
1213
include_bytes!("../assets/Intel_SGX_Provisioning_Certification_RootCA.der");
13-
// TODO This is not root of trust, so we should get it via network
14-
const INTEL_ROOT_CA_CRL: &'static [u8] = include_bytes!("../assets/IntelSGXRootCA.der");
1514

1615
pub fn run_dcap_ra(
1716
key_manager: &EnclaveKeyManager,
@@ -26,6 +25,7 @@ pub fn run_dcap_ra(
2625
let raw_quote = rsgx_qe_get_quote(&ek_info.report).unwrap();
2726
let quote = QuoteV3::from_bytes(&raw_quote);
2827
println!("Successfully get the quote: {:?}", quote);
28+
2929
let current_time = Time::now();
3030
key_manager
3131
.save_verifiable_quote(
@@ -54,8 +54,9 @@ fn rsgx_qe_get_quote(app_report: &sgx_report_t) -> Result<Vec<u8>, sgx_quote3_er
5454
}
5555
}
5656

57-
pub async fn get_collateral(pccs_url: &str, quote: &QuoteV3) -> IntelCollateral {
57+
async fn get_collateral(pccs_url: &str, quote: &QuoteV3) -> IntelCollateral {
5858
let base_url = format!("{}/sgx/certification/v4", pccs_url.trim_end_matches('/'));
59+
info!("base_url: {}", base_url);
5960
assert_eq!(
6061
quote.signature.qe_cert_data.cert_data_type, 5,
6162
"QE Cert Type must be 5"
@@ -70,15 +71,9 @@ pub async fn get_collateral(pccs_url: &str, quote: &QuoteV3) -> IntelCollateral
7071
let sgx_extensions = extract_sgx_extension(&pck_cert);
7172
let fmspc = hex::encode_upper(sgx_extensions.fmspc);
7273

73-
let builder = reqwest::Client::builder();
74-
let client = builder.build().unwrap();
75-
74+
let client = reqwest::Client::new();
7675
let mut collateral = IntelCollateral::new();
7776
{
78-
println!(
79-
"Getting TCB info from {}",
80-
format!("{base_url}/tcb?fmspc={fmspc}")
81-
);
8277
let res = client
8378
.get(format!("{base_url}/tcb?fmspc={fmspc}"))
8479
.send()
@@ -94,38 +89,41 @@ pub async fn get_collateral(pccs_url: &str, quote: &QuoteV3) -> IntelCollateral
9489
collateral.set_tcbinfo_bytes(res.bytes().await.unwrap().as_ref());
9590
}
9691

97-
// let qe_identity_issuer_chain;
9892
{
99-
let response = client
93+
let res = client
10094
.get(format!("{base_url}/qe/identity"))
10195
.send()
10296
.await
10397
.unwrap();
104-
// qe_identity_issuer_chain = get_header(&response, "SGX-Enclave-Identity-Issuer-Chain").unwrap();
105-
let raw_qe_identity = response.text().await.unwrap();
106-
collateral.set_qeidentity_bytes(raw_qe_identity.as_bytes());
98+
collateral.set_qeidentity_bytes(res.bytes().await.unwrap().as_ref());
10799
}
108100
collateral.set_intel_root_ca_der(INTEL_ROOT_CA);
109101

110-
collateral.set_sgx_intel_root_ca_crl_der(INTEL_ROOT_CA_CRL);
102+
{
103+
let res = client
104+
.get("https://certificates.trustedservices.intel.com/IntelSGXRootCA.der")
105+
.send()
106+
.await
107+
.unwrap();
108+
let crl = res.bytes().await.unwrap();
109+
collateral.set_sgx_intel_root_ca_crl_der(&crl);
110+
}
111111

112112
{
113113
let res = client
114114
.get(format!("{base_url}/pckcrl?ca=processor&encoding=der"))
115115
.send()
116116
.await
117117
.unwrap();
118-
let crl = res.bytes().await.unwrap();
119-
collateral.set_sgx_processor_crl_der(&crl);
118+
collateral.set_sgx_processor_crl_der(res.bytes().await.unwrap().as_ref());
120119
}
121120
{
122121
let res = client
123122
.get(format!("{base_url}/pckcrl?ca=platform&encoding=der"))
124123
.send()
125124
.await
126125
.unwrap();
127-
let crl = res.bytes().await.unwrap();
128-
collateral.set_sgx_platform_crl_der(&crl);
126+
collateral.set_sgx_platform_crl_der(res.bytes().await.unwrap().as_ref());
129127
}
130128

131129
collateral

0 commit comments

Comments
 (0)