Skip to content

Commit

Permalink
Error handle http response in GetTdxQuote command
Browse files Browse the repository at this point in the history
  • Loading branch information
ameba23 committed Dec 6, 2024
1 parent 732c1d5 commit d385082
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/test-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,13 @@ pub async fn run_command(
},
CliCommand::GetTdxQuote { tss_endpoint, output_filename } => {
// TODO add context
let quote_bytes =
reqwest::get(format!("http://{}/attest", tss_endpoint)).await?.bytes().await?;
let response =
reqwest::get(format!("http://{}/attest?context=change_endpoint", tss_endpoint))
.await?;
if response.status() != reqwest::StatusCode::OK {
return Err(anyhow!(response.text().await?));
}
let quote_bytes = response.bytes().await?;
let output_filename = output_filename.unwrap_or("quote.dat".into());

std::fs::write(&output_filename, quote_bytes)?;
Expand Down

0 comments on commit d385082

Please sign in to comment.