Implement certificate delete
A deletion of a certificate is invoked by calling the DELETE verb on the
certificate REST endpoint. This application intercepts this and deletes
the certificate file. It also reloads/restarts the associated systemd
unit, which may generate a self-signed certificate.
Change-Id: I879551c1aff160cab0c07d1c73ae147f85a6e17e
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/certs_manager.hpp b/certs_manager.hpp
index 027317e..7d42d01 100644
--- a/certs_manager.hpp
+++ b/certs_manager.hpp
@@ -6,6 +6,7 @@
#include <sdbusplus/server/object.hpp>
#include <unordered_map>
#include <xyz/openbmc_project/Certs/Install/server.hpp>
+#include <xyz/openbmc_project/Object/Delete/server.hpp>
namespace phosphor
{
@@ -18,12 +19,13 @@
static constexpr auto SERVER = "server";
static constexpr auto CLIENT = "client";
-using CreateIface = sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Certs::server::Install>;
+using Create = sdbusplus::xyz::openbmc_project::Certs::server::Install;
+using Delete = sdbusplus::xyz::openbmc_project::Object::server::Delete;
+using Ifaces = sdbusplus::server::object::object<Create, Delete>;
using InstallFunc = std::function<void()>;
using InputType = std::string;
-class Manager : public CreateIface
+class Manager : public Ifaces
{
public:
/* Define all of the basic class operations:
@@ -52,7 +54,7 @@
*/
Manager(sdbusplus::bus::bus& bus, const char* path, const std::string& type,
std::string&& unit, std::string&& certPath) :
- CreateIface(bus, path),
+ Ifaces(bus, path),
bus(bus), path(path), type(type), unit(std::move(unit)),
certPath(std::move(certPath))
{
@@ -70,6 +72,11 @@
*/
void install(const std::string path) override;
+ /** @brief Delete the certificate (and possibly revert
+ * to a self-signed certificate).
+ */
+ void delete_() override;
+
private:
/** @brief Client certificate Installation helper function **/
virtual void clientInstall();