diff --git a/src/node/node_state.h b/src/node/node_state.h index 2ed39613cc85..141425fe50cf 100644 --- a/src/node/node_state.h +++ b/src/node/node_state.h @@ -398,52 +398,57 @@ namespace ccf void initiate_quote_generation() { - auto fetch_endorsements = - [this]( - const QuoteInfo& qi, - const pal::snp::EndorsementEndpointsConfiguration& endpoint_config) { - // Note: Node lock is already taken here as this is called back - // synchronously with the call to pal::generate_quote - - if (qi.format == QuoteFormat::amd_sev_snp_v1) + auto fetch_endorsements = [this]( + const QuoteInfo& qi, + const pal::snp:: + EndorsementEndpointsConfiguration& + endpoint_config) { + // Note: Node lock is already taken here as this is called back + // synchronously with the call to pal::generate_quote + + if (qi.format == QuoteFormat::amd_sev_snp_v1) + { + if (!config.attestation.snp_endorsements_servers.empty()) { - CCF_ASSERT_FMT( - !config.attestation.snp_endorsements_servers.empty(), + throw std::runtime_error( "One or more SNP endorsements servers must be specified to fetch " "the collateral for the attestation"); - // On SEV-SNP, fetch endorsements from servers if specified - quote_endorsements_client = - std::make_shared( - rpcsessions, - endpoint_config, - [this, qi](std::vector&& endorsements) { - std::lock_guard guard(lock); - quote_info = qi; - quote_info.endorsements = std::move(endorsements); - try - { - launch_node(); - } - catch (const std::exception& e) - { - LOG_FAIL_FMT("{}", e.what()); - throw; - } - quote_endorsements_client.reset(); - }); - - quote_endorsements_client->fetch_endorsements(); - return; } + // On SEV-SNP, fetch endorsements from servers if specified + quote_endorsements_client = std::make_shared( + rpcsessions, + endpoint_config, + [this, qi](std::vector&& endorsements) { + std::lock_guard guard(lock); + quote_info = qi; + quote_info.endorsements = std::move(endorsements); + try + { + launch_node(); + } + catch (const std::exception& e) + { + LOG_FAIL_FMT("{}", e.what()); + throw; + } + quote_endorsements_client.reset(); + }); - CCF_ASSERT_FMT( - (qi.format == QuoteFormat::oe_sgx_v1 && !qi.endorsements.empty()) || - (qi.format != QuoteFormat::oe_sgx_v1 && qi.endorsements.empty()), + quote_endorsements_client->fetch_endorsements(); + return; + } + + if (!((qi.format == QuoteFormat::oe_sgx_v1 && + !qi.endorsements.empty()) || + (qi.format != QuoteFormat::oe_sgx_v1 && qi.endorsements.empty()))) + { + throw std::runtime_error( "SGX quote generation should have already fetched endorsements"); + } - quote_info = qi; - launch_node(); - }; + quote_info = qi; + launch_node(); + }; pal::PlatformAttestationReportData report_data = crypto::Sha256Hash((node_sign_kp->public_key_der()));