From 2d9b617c93d09354696dc11ef185ecd9ae1d8b80 Mon Sep 17 00:00:00 2001 From: brenzi Date: Tue, 6 Jun 2023 17:38:26 +0200 Subject: [PATCH] Dcap debugging helpers (#1346) * introduce attesteer compiler flag * panic if DCAP collateral registration fails * revert and just leave logging * try to get err from null * try to get err from null... * cosmetics * cosmetics * cosmetics * cosmetics * cosmetics --- .../enclave-api/src/remote_attestation.rs | 18 +++++++++--------- service/Cargo.toml | 1 + service/src/main.rs | 9 +++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/core-primitives/enclave-api/src/remote_attestation.rs b/core-primitives/enclave-api/src/remote_attestation.rs index 11399201fa..8c6eda0c41 100644 --- a/core-primitives/enclave-api/src/remote_attestation.rs +++ b/core-primitives/enclave-api/src/remote_attestation.rs @@ -409,27 +409,27 @@ impl RemoteAttestation for Enclave { pck_crl_size: {}\n, \ tcb_info_issuer_chain: {:?}\n, \ tcb_info_issuer_chain_size: {}\n, \ - tcb_info: {:?}\n, \ + tcb_info: {}\n, \ tcb_info_size: {}\n, \ qe_identity_issuer_chain: {:?}\n, \ qe_identity_issuer_chain_size: {}\n, \ - qe_identity: {:?}\n, \ + qe_identity: {}\n, \ qe_identity_size: {}\n", collateral.version, collateral.tee_type, - std::ffi::CStr::from_ptr(collateral.pck_crl_issuer_chain).to_str().unwrap(), + std::ffi::CStr::from_ptr(collateral.pck_crl_issuer_chain).to_string_lossy(), collateral.pck_crl_issuer_chain_size, - std::ffi::CStr::from_ptr(collateral.root_ca_crl).to_str().unwrap(), + std::ffi::CStr::from_ptr(collateral.root_ca_crl).to_string_lossy(), collateral.root_ca_crl_size, - std::ffi::CStr::from_ptr(collateral.pck_crl).to_str().unwrap(), + std::ffi::CStr::from_ptr(collateral.pck_crl).to_string_lossy(), collateral.pck_crl_size, - std::ffi::CStr::from_ptr(collateral.tcb_info_issuer_chain).to_str().unwrap(), + std::ffi::CStr::from_ptr(collateral.tcb_info_issuer_chain).to_string_lossy(), collateral.tcb_info_issuer_chain_size, - std::ffi::CStr::from_ptr(collateral.tcb_info).to_str().unwrap(), + std::ffi::CStr::from_ptr(collateral.tcb_info).to_string_lossy(), collateral.tcb_info_size, - std::ffi::CStr::from_ptr(collateral.qe_identity_issuer_chain).to_str().unwrap(), + std::ffi::CStr::from_ptr(collateral.qe_identity_issuer_chain).to_string_lossy(), collateral.qe_identity_issuer_chain_size, - std::ffi::CStr::from_ptr(collateral.qe_identity).to_str().unwrap(), + std::ffi::CStr::from_ptr(collateral.qe_identity).to_string_lossy(), collateral.qe_identity_size, ); }; diff --git a/service/Cargo.toml b/service/Cargo.toml index 34f9a92ce3..01c69708e7 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -83,6 +83,7 @@ offchain-worker = ["itp-settings/offchain-worker"] production = ["itp-settings/production"] teeracle = ["itp-settings/teeracle"] dcap = [] +attesteer = [] [dev-dependencies] # crates.io diff --git a/service/src/main.rs b/service/src/main.rs index 4dbe5777a9..6dfb6acb4c 100644 --- a/service/src/main.rs +++ b/service/src/main.rs @@ -427,11 +427,11 @@ fn start_worker( register_collateral(&node_api, &*enclave, &tee_accountid, is_development_mode, skip_ra); let trusted_url = config.trusted_worker_url_external(); - #[cfg(feature = "dcap")] + #[cfg(feature = "attesteer")] let marblerun_base_url = run_config.marblerun_base_url.unwrap_or("http://localhost:9944".to_owned()); - #[cfg(feature = "dcap")] + #[cfg(feature = "attesteer")] fetch_marblerun_events_every_hour( node_api.clone(), enclave.clone(), @@ -762,10 +762,11 @@ fn register_collateral( let dcap_quote = enclave.generate_dcap_ra_quote(skip_ra).unwrap(); if !skip_ra { let (fmspc, _tcb_info) = extract_tcb_info_from_raw_dcap_quote(&dcap_quote).unwrap(); - + println!("[>] DCAP setup: register QE collateral"); let uxt = enclave.generate_register_quoting_enclave_extrinsic(fmspc).unwrap(); send_extrinsic(uxt, api, accountid, is_development_mode); + println!("[>] DCAP setup: register TCB info"); let uxt = enclave.generate_register_tcb_info_extrinsic(fmspc).unwrap(); send_extrinsic(uxt, api, accountid, is_development_mode); } @@ -784,7 +785,7 @@ fn send_extrinsic( return None } - println!("[>] Register the TCB info (send the extrinsic)"); + println!("[>] send extrinsic"); match api.submit_and_watch_opaque_extrinsic_until_success(extrinsic.into(), true) { Ok(xt_report) => {