From 4a7960f21b250587eb9b069f52cc60b0c780d62c Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 8 Jan 2019 11:49:44 +0100 Subject: [PATCH] pki::RequestCertificate: handle missing certificate/CSR --- lib/remote/jsonrpcconnection-pki.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/remote/jsonrpcconnection-pki.cpp b/lib/remote/jsonrpcconnection-pki.cpp index f0ec8fe1b..0c48b3d04 100644 --- a/lib/remote/jsonrpcconnection-pki.cpp +++ b/lib/remote/jsonrpcconnection-pki.cpp @@ -52,6 +52,15 @@ Value RequestCertificateHandler(const MessageOrigin::Ptr& origin, const Dictiona else cert = StringToCertificate(certText); + if (!cert) { + Log(LogWarning, "JsonRpcConnection") << "No certificate or CSR received"; + + result->Set("status_code", 1); + result->Set("error", "No certificate or CSR received."); + + return result; + } + ApiListener::Ptr listener = ApiListener::GetInstance(); std::shared_ptr cacert = GetX509Certificate(listener->GetDefaultCaPath()); -- 2.40.0