From 90ac6cd9a142774aa278018c544e756eafa1f62f Mon Sep 17 00:00:00 2001 From: Michael Insel Date: Thu, 13 Feb 2020 19:40:32 +0100 Subject: [PATCH 1/2] CLI: Catch exception when trusted cert is not readable This catches an exception when the trusted cert is not readable during node setup. --- lib/cli/nodesetupcommand.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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() << "'."; From e4f25269fee0bd74ff2fa5496088d23d8082f464 Mon Sep 17 00:00:00 2001 From: Michael Insel Date: Fri, 14 Feb 2020 07:56:23 +0100 Subject: [PATCH 2/2] Fix Build I have no idea how this got lost. --- lib/cli/nodesetupcommand.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cli/nodesetupcommand.cpp b/lib/cli/nodesetupcommand.cpp index d02367ba4..eef67af47 100644 --- a/lib/cli/nodesetupcommand.cpp +++ b/lib/cli/nodesetupcommand.cpp @@ -376,7 +376,7 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm, String trustedCert = vm["trustedcert"].as(); try{ - trustedParentCert = GetX509Certificate(trustedCert) + trustedParentCert = GetX509Certificate(trustedCert); } catch (const std::exception&) { Log(LogCritical, "cli") << "Can't read trusted cert at '" << trustedCert << "'.";