Skip to content

Commit

Permalink
Certificate delete API – middleware
Browse files Browse the repository at this point in the history
With introducing Mutual-TLS and option to add multiple certificates
there is a need to give user a possibility to remove them, for example
when they expire. This commit adds implementation of DELETE function
to TLS Certificate node, so each of them can be removed.

Beckend implementation is here:
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-certificate-manager/+/25268

Tested with uploaded multiple TLS certificates.
Other certificates remains irremovable as they were so far.

Signed-off-by: Zbigniew Kurzynski <zbigniew.kurzynski@intel.com>
Change-Id: I9781c5c79288ec5d080e80e42c63a55e471ddb77
Depends-On: I9dd6fa998e8bd8081fbd13549831bc94a4a7aa54
  • Loading branch information
zkurzyns committed Nov 6, 2019
1 parent 66b5ca7 commit 07a6029
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions redfish-core/lib/certificate_service.hpp
Expand Up @@ -26,6 +26,7 @@ constexpr char const *httpsObjectPath =
"/xyz/openbmc_project/certs/server/https";
constexpr char const *certInstallIntf = "xyz.openbmc_project.Certs.Install";
constexpr char const *certReplaceIntf = "xyz.openbmc_project.Certs.Replace";
constexpr char const *objDeleteIntf = "xyz.openbmc_project.Object.Delete";
constexpr char const *certPropIntf = "xyz.openbmc_project.Certs.Certificate";
constexpr char const *dbusPropIntf = "org.freedesktop.DBus.Properties";
constexpr char const *dbusObjManagerIntf = "org.freedesktop.DBus.ObjectManager";
Expand Down Expand Up @@ -1363,5 +1364,46 @@ class TrustStoreCertificate : public Node
certs::authorityServiceName, id, certURL,
"TrustStore Certificate");
}

void doDelete(crow::Response &res, const crow::Request &req,
const std::vector<std::string> &params) override
{
auto asyncResp = std::make_shared<AsyncResp>(res);

if (params.size() != 1)
{
messages::internalError(asyncResp->res);
return;
}

long id = getIDFromURL(req.url);
if (id < 0)
{
BMCWEB_LOG_ERROR << "Invalid url value: " << req.url;
messages::resourceNotFound(asyncResp->res, "TrustStore Certificate",
std::string(req.url));
return;
}
BMCWEB_LOG_DEBUG << "TrustStoreCertificate::doDelete ID="
<< std::to_string(id);
std::string certPath = certs::authorityObjectPath;
certPath += "/";
certPath += std::to_string(id);

crow::connections::systemBus->async_method_call(
[asyncResp, id](const boost::system::error_code ec) {
if (ec)
{
messages::resourceNotFound(asyncResp->res,
"TrustStore Certificate",
std::to_string(id));
return;
}
BMCWEB_LOG_INFO << "Certificate deleted";
asyncResp->res.result(boost::beast::http::status::no_content);
},
certs::authorityServiceName, certPath, certs::objDeleteIntf,
"Delete");
}
}; // TrustStoreCertificate
} // namespace redfish

0 comments on commit 07a6029

Please sign in to comment.