]> granicus.if.org Git - icinga2/commitdiff
pki::RequestCertificate: handle missing certificate/CSR 6880/head
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Tue, 8 Jan 2019 10:49:44 +0000 (11:49 +0100)
committerAlexander A. Klimov <alexander.klimov@icinga.com>
Tue, 8 Jan 2019 10:49:44 +0000 (11:49 +0100)
lib/remote/jsonrpcconnection-pki.cpp

index f0ec8fe1b248fe13daeaac9b9d5a92802fce4c53..0c48b3d042dc9fbe5a7069c09695ace527592d1f 100644 (file)
@@ -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<X509> cacert = GetX509Certificate(listener->GetDefaultCaPath());