Support uploading multiple certificates [install-middlewere]
This review is a fix for changes in Install API.
See review:
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-certificate-manager/+/25634
Tested: Tested manaually, the POST method on certificate collection returns ID
of created certificate.
Signed-off-by: Zbigniew Kurzynski <zbigniew.kurzynski@intel.com>
Depends-On: Ic8ab545c931d89a022acdabd5a755e3bf39e5a79
Change-Id: I70c449600623e4f1eabf63c23163683f6f513d43
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 89d5634..5fdff1f 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -937,21 +937,26 @@
std::make_shared<CertificateFile>(certFileBody);
crow::connections::systemBus->async_method_call(
- [asyncResp, certFile](const boost::system::error_code ec) {
+ [asyncResp, certFile](const boost::system::error_code ec,
+ const std::string &objectPath) {
if (ec)
{
BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
messages::internalError(asyncResp->res);
return;
}
- // TODO: Issue#84 supporting only 1 certificate
- long certId = 1;
+ long certId = getIDFromURL(objectPath);
+ if (certId < 0)
+ {
+ BMCWEB_LOG_ERROR << "Invalid objectPath value"
+ << objectPath;
+ messages::internalError(asyncResp->res);
+ return;
+ }
std::string certURL =
"/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/"
"Certificates/" +
std::to_string(certId);
- std::string objectPath = std::string(certs::httpsObjectPath) +
- "/" + std::to_string(certId);
getCertificateProperties(asyncResp, objectPath,
certs::httpsServiceName, certId,
certURL, "HTTPS Certificate");
@@ -1131,20 +1136,25 @@
std::make_shared<CertificateFile>(certFileBody);
crow::connections::systemBus->async_method_call(
- [asyncResp, certFile](const boost::system::error_code ec) {
+ [asyncResp, certFile](const boost::system::error_code ec,
+ const std::string &objectPath) {
if (ec)
{
BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
messages::internalError(asyncResp->res);
return;
}
- //// TODO: Issue#84 supporting only 1 certificate
- long certId = 1;
+ long certId = getIDFromURL(objectPath);
+ if (certId < 0)
+ {
+ BMCWEB_LOG_ERROR << "Invalid objectPath value"
+ << objectPath;
+ messages::internalError(asyncResp->res);
+ return;
+ }
std::string certURL =
"/redfish/v1/AccountService/LDAP/Certificates/" +
std::to_string(certId);
- std::string objectPath = std::string(certs::ldapObjectPath) +
- "/" + std::to_string(certId);
getCertificateProperties(asyncResp, objectPath,
certs::ldapServiceName, certId,
certURL, "LDAP Certificate");
@@ -1265,21 +1275,26 @@
std::make_shared<CertificateFile>(req.body);
auto asyncResp = std::make_shared<AsyncResp>(res);
crow::connections::systemBus->async_method_call(
- [asyncResp, certFile](const boost::system::error_code ec) {
+ [asyncResp, certFile](const boost::system::error_code ec,
+ const std::string &objectPath) {
if (ec)
{
BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
messages::internalError(asyncResp->res);
return;
}
- //// TODO: Issue#84 supporting only 1 certificate
- long certId = 1;
+ long certId = getIDFromURL(objectPath);
+ if (certId < 0)
+ {
+ BMCWEB_LOG_ERROR << "Invalid objectPath value"
+ << objectPath;
+ messages::internalError(asyncResp->res);
+ return;
+ }
std::string certURL = "/redfish/v1/Managers/bmc/"
"Truststore/Certificates/" +
std::to_string(certId);
- std::string objectPath =
- std::string(certs::authorityObjectPath) + "/" +
- std::to_string(certId);
+
getCertificateProperties(asyncResp, objectPath,
certs::authorityServiceName, certId,
certURL, "TrustStore Certificate");