CLI: Catch exception when trusted cert is not readable

This catches an exception when the trusted cert is not readable during
node setup.
This commit is contained in:
Michael Insel 2020-02-13 19:40:32 +01:00
parent be2178b993
commit 90ac6cd9a1
1 changed files with 9 additions and 1 deletions

View File

@ -373,7 +373,15 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
return 1;
}
trustedParentCert = GetX509Certificate(vm["trustedcert"].as<std::string>());
String trustedCert = vm["trustedcert"].as<std::string>();
try{
trustedParentCert = GetX509Certificate(trustedCert)
} catch (const std::exception&) {
Log(LogCritical, "cli")
<< "Can't read trusted cert at '" << trustedCert << "'.";
return 1;
}
Log(LogInformation, "cli")
<< "Verifying trusted certificate file '" << vm["trustedcert"].as<std::string>() << "'.";