WIP async 2

This commit is contained in:
Ajinkya Kulkarni 2024-12-03 10:38:50 +01:00
parent cdd11858f6
commit e84ef9b417
2 changed files with 5 additions and 3 deletions

View file

@ -28,6 +28,7 @@ async fn get_tcbinfo(fmspc: Fmspc, update: Update) -> Value {
.await .await
.expect("url retrieval failed") .expect("url retrieval failed")
.text() .text()
.await
.expect("could not read https response"); .expect("could not read https response");
let tcbinfo: Value = serde_json::from_str(&body).expect("could not convert to JSON"); let tcbinfo: Value = serde_json::from_str(&body).expect("could not convert to JSON");
tcbinfo tcbinfo
@ -38,6 +39,7 @@ async fn get_fmspc_list() -> Vec<Fmspc> {
reqwest::get("https://api.trustedservices.intel.com/sgx/certification/v4/fmspcs").await reqwest::get("https://api.trustedservices.intel.com/sgx/certification/v4/fmspcs").await
.expect("url retrieval failed") .expect("url retrieval failed")
.text() .text()
.await
.expect("could not read https response"); .expect("could not read https response");
let fmspc_data: Vec<Value> = serde_json::from_str(&body).expect("could not convert to JSON"); let fmspc_data: Vec<Value> = serde_json::from_str(&body).expect("could not convert to JSON");
let mut fmspc_list: Vec<Fmspc> = Vec::new(); let mut fmspc_list: Vec<Fmspc> = Vec::new();
@ -54,9 +56,9 @@ async fn upsert_tcbinfo() -> Result<(), &'static str> {
let data = fs::read_to_string("./standard").expect("Unable to read file"); let data = fs::read_to_string("./standard").expect("Unable to read file");
let mut store: HashMap<Fmspc, TcbInfo> = serde_json::from_str(&data).unwrap(); let mut store: HashMap<Fmspc, TcbInfo> = serde_json::from_str(&data).unwrap();
let fmspc_list = get_fmspc_list(); let fmspc_list = get_fmspc_list().await;
for fmspc in fmspc_list { for fmspc in fmspc_list {
let tcbinfo = get_tcbinfo(fmspc.clone(), "standard".to_string()); let tcbinfo = get_tcbinfo(fmspc.clone(), "standard".to_string()).await;
let store_entry = &store[&fmspc]; let store_entry = &store[&fmspc];
if *store_entry != tcbinfo { if *store_entry != tcbinfo {
println!("updating local TCBInfo for FMSPC: {fmspc}"); println!("updating local TCBInfo for FMSPC: {fmspc}");

File diff suppressed because one or more lines are too long