summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorZbigniew Kurzynski <zbigniew.kurzynski@intel.com>2019-09-30 19:43:28 +0300
committerEd Tanous <ed.tanous@intel.com>2019-10-11 02:31:34 +0300
commit656ec7e317a5ebf0e8dd3068f321a54cebea2273 (patch)
tree54fe834ab14776821328ac7e58bdfd43b7a20364 /redfish-core
parent271584ab78b4c1926f766aa26ddfde7da329059f (diff)
downloadbmcweb-656ec7e317a5ebf0e8dd3068f321a54cebea2273.tar.xz
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
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/certificate_service.hpp47
1 files changed, 31 insertions, 16 deletions
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 89d563479c..5fdff1fce9 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -937,21 +937,26 @@ class HTTPSCertificateCollection : public Node
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 @@ class LDAPCertificateCollection : public Node
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 @@ class TrustStoreCertificateCollection : public Node
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");