feat: check for provisioning state on shbc failure and reset if necessary

This commit is contained in:
Mudit Vats
2021-08-11 09:56:36 -07:00
parent 706a512bc7
commit 185cdceadb
3 changed files with 59 additions and 0 deletions

View File

@@ -293,6 +293,29 @@ int main(int argc, char* argv[])
server_cert.algorithm = certAlgo;
server_cert.hash = certHash;
bool sbhc_success = cmd_start_config_host_based(server_cert, amt_cert);
if (!sbhc_success)
{
int state;
if (cmd_get_provisioning_state(state))
{
switch (state) {
case 0:
std::cout << "Provisioning state already in pre-provisioning." << std::endl;
break;
case 1:
std::cout << "Provisioning state is in-provisioning." << std::endl;
(cmd_stop_configuration()) ? std::cout << "Provisioning state succesfully reset." : std::cout << "Provisioning state could not be reset.";
break;
case 2:
std::cout << "Provisioning state is post-provisioning." << std::endl;
(cmd_stop_configuration()) ? std::cout << "Provisioning state succesfully reset." : std::cout << "Provisioning state could not be reset.";
break;
default:
break;
}
}
}
// create the response
std::string response;