diff options
author | Jiaqing Zhao <jiaqing.zhao@intel.com> | 2022-09-29 10:15:58 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-10-04 00:07:33 +0300 |
commit | 7a3a8f7aa20017a1bdb4f22737f03a12d0930f19 (patch) | |
tree | 8efb9330a533829336cb8454a9fa2eb9c2292b75 /redfish-core | |
parent | e2415fa730a2b11e465d2453207281578c04dfd0 (diff) | |
download | bmcweb-7a3a8f7aa20017a1bdb4f22737f03a12d0930f19.tar.xz |
certificate: Add deleteCertificate function
This patch adds deleteCertificate function to delete an installed cert,
which is used in current DELETE TrustStore cert handler and incoming
DELETE LDAP client store cert handler. Compared to having two lambdas,
it reduces code redundancy and has slightly smaller compressed binary
size (~700B).
Tested:
Code move only, DELETE /redfish/v1/Managers/bmc/Truststore/Certificates
/<id> works exactly the same as before.
Change-Id: I93c07845e4be3c0304b3c3e8ff4249885c9ab908
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
Diffstat (limited to 'redfish-core')
-rw-r--r-- | redfish-core/lib/certificate_service.hpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp index 8701f59f17..cb8979277e 100644 --- a/redfish-core/lib/certificate_service.hpp +++ b/redfish-core/lib/certificate_service.hpp @@ -376,6 +376,25 @@ static void getCertificateProperties( }); } +static void + deleteCertificate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& service, + const sdbusplus::message::object_path& objectPath) +{ + crow::connections::systemBus->async_method_call( + [asyncResp, + id{objectPath.filename()}](const boost::system::error_code ec) { + if (ec) + { + messages::resourceNotFound(asyncResp->res, "Certificate", id); + return; + } + BMCWEB_LOG_INFO << "Certificate deleted"; + asyncResp->res.result(boost::beast::http::status::no_content); + }, + service, objectPath, certs::objDeleteIntf, "Delete"); +} + inline void handleCertificateServiceGet( App& app, const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) @@ -1164,17 +1183,7 @@ inline void handleTrustStoreCertificateDelete( std::string objPath = sdbusplus::message::object_path(certs::authorityObjectPath) / id; - crow::connections::systemBus->async_method_call( - [asyncResp, id](const boost::system::error_code ec) { - if (ec) - { - messages::resourceNotFound(asyncResp->res, "Certificate", id); - return; - } - BMCWEB_LOG_INFO << "Certificate deleted"; - asyncResp->res.result(boost::beast::http::status::no_content); - }, - certs::authorityServiceName, objPath, certs::objDeleteIntf, "Delete"); + deleteCertificate(asyncResp, certs::authorityServiceName, objPath); } inline void requestRoutesTrustStoreCertificate(App& app) |