Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Merge #2178
Browse files Browse the repository at this point in the history
2178: Problem: ra-sp-server crashes sometimes r=tomtau a=devashishdxt

Solution: Added 6 retries for `AesmClient` at an interval of 2 secs each. Fixes #2175.

Co-authored-by: Devashish <[email protected]>
  • Loading branch information
bors[bot] and devashishdxt authored Aug 25, 2020
2 parents 0d88fc1 + 7aa5999 commit 92f7f27
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions chain-tx-enclave-next/enclave-ra/ra-sp-server/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ impl SpRaContext {
/// Creates a new SP remote attestation context
pub fn new(config: SpRaConfig) -> Result<Self, SpRaContextError> {
let aesm_client = AesmClient::new();
let quote_info = aesm_client
.init_quote()
.map_err(SpRaContextError::AesmError)?;
let quote_info = get_quote_info(&aesm_client)?;
let quote_type = config.quote_type;

let ias_client = IasClient::new(
Expand Down Expand Up @@ -95,6 +93,19 @@ impl SpRaContext {
}
}

fn get_quote_info(aesm_client: &AesmClient) -> Result<QuoteInfo, SpRaContextError> {
for _ in 0..5 {
match aesm_client.init_quote() {
Ok(quote_info) => return Ok(quote_info),
Err(_) => std::thread::sleep(std::time::Duration::from_secs(2)),
}
}

aesm_client
.init_quote()
.map_err(SpRaContextError::AesmError)
}

fn parse_quote_type(quote_type: &str) -> Result<QuoteType, SpRaContextError> {
match quote_type {
"Linkable" => Ok(QuoteType::Linkable),
Expand Down

0 comments on commit 92f7f27

Please sign in to comment.