diff --git a/lib/cli/nodesetupcommand.cpp b/lib/cli/nodesetupcommand.cpp index ad21f1d72..d02367ba4 100644 --- a/lib/cli/nodesetupcommand.cpp +++ b/lib/cli/nodesetupcommand.cpp @@ -373,7 +373,15 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm, return 1; } - trustedParentCert = GetX509Certificate(vm["trustedcert"].as()); + String trustedCert = vm["trustedcert"].as(); + + 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() << "'.";