summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiaqing Zhao <jiaqing.zhao@intel.com>2022-06-06 14:43:39 +0300
committerEd Tanous <ed@tanous.net>2022-08-01 01:11:56 +0300
commite19e97e247880345aefdf51f557cf1f18d25a5bb (patch)
treea1a3f7ee91ff306596fc8f7c1823bdec2ff93d21
parent3648c8be1c03c8ebe099185bc651613862fc0027 (diff)
downloadbmcweb-e19e97e247880345aefdf51f557cf1f18d25a5bb.tar.xz
certificate: Use string certId in getCertificateProperties
Current implementation assumes only the DBus paths with numbers are the paths for certificates, so here certId is of type long int. This patch changes the type to std::string for removing such incorrect assumption in future commits as dbus paths are not limited to numbers. Tested: * Verified both GET Certificate and POST CertificateCollection works. * Redfish Service Validator passed. Change-Id: I747adf4bf955194f82650a11f9dc11a85e00d6e4 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
-rw-r--r--redfish-core/lib/certificate_service.hpp47
1 files changed, 24 insertions, 23 deletions
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 22d77a728b..0c1bc623a9 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -640,8 +640,9 @@ static void
*/
static void getCertificateProperties(
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& objectPath, const std::string& service, long certId,
- const std::string& certURL, const std::string& name)
+ const std::string& objectPath, const std::string& service,
+ const std::string& certId, const std::string& certURL,
+ const std::string& name)
{
BMCWEB_LOG_DEBUG << "getCertificateProperties Path=" << objectPath
<< " certId=" << certId << " certURl=" << certURL;
@@ -652,14 +653,13 @@ static void getCertificateProperties(
if (ec)
{
BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
- messages::resourceNotFound(asyncResp->res, name,
- std::to_string(certId));
+ messages::resourceNotFound(asyncResp->res, name, certId);
return;
}
asyncResp->res.jsonValue["@odata.id"] = certURL;
asyncResp->res.jsonValue["@odata.type"] =
"#Certificate.v1_0_0.Certificate";
- asyncResp->res.jsonValue["Id"] = std::to_string(certId);
+ asyncResp->res.jsonValue["Id"] = certId;
asyncResp->res.jsonValue["Name"] = name;
asyncResp->res.jsonValue["Description"] = name;
for (const auto& property : properties)
@@ -845,8 +845,8 @@ inline void requestRoutesCertificateActionsReplaceCertificate(App& app)
messages::internalError(asyncResp->res);
return;
}
- getCertificateProperties(asyncResp, objectPath, service, id,
- certURI, name);
+ getCertificateProperties(asyncResp, objectPath, service,
+ std::to_string(id), certURI, name);
BMCWEB_LOG_DEBUG << "HTTPS certificate install file="
<< certFile->getCertFilePath();
},
@@ -890,9 +890,9 @@ inline void requestRoutesHTTPSCertificate(App& app)
std::string objectPath = certs::httpsObjectPath;
objectPath += "/";
objectPath += std::to_string(id);
- getCertificateProperties(asyncResp, objectPath,
- certs::httpsServiceName, id, certURL,
- "HTTPS Certificate");
+ getCertificateProperties(
+ asyncResp, objectPath, certs::httpsServiceName,
+ std::to_string(id), certURL, "HTTPS Certificate");
});
}
@@ -971,9 +971,9 @@ inline void requestRoutesHTTPSCertificateCollection(App& app)
std::string certURL =
"/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates/" +
std::to_string(certId);
- getCertificateProperties(asyncResp, objectPath,
- certs::httpsServiceName, certId, certURL,
- "HTTPS Certificate");
+ getCertificateProperties(
+ asyncResp, objectPath, certs::httpsServiceName,
+ std::to_string(certId), certURL, "HTTPS Certificate");
BMCWEB_LOG_DEBUG << "HTTPS certificate install file="
<< certFile->getCertFilePath();
},
@@ -1082,9 +1082,9 @@ inline void requestRoutesLDAPCertificateCollection(App& app)
std::string certURL =
"/redfish/v1/AccountService/LDAP/Certificates/" +
std::to_string(certId);
- getCertificateProperties(asyncResp, objectPath,
- certs::ldapServiceName, certId, certURL,
- "LDAP Certificate");
+ getCertificateProperties(
+ asyncResp, objectPath, certs::ldapServiceName,
+ std::to_string(certId), certURL, "LDAP Certificate");
BMCWEB_LOG_DEBUG << "LDAP certificate install file="
<< certFile->getCertFilePath();
},
@@ -1123,7 +1123,8 @@ inline void requestRoutesLDAPCertificate(App& app)
objectPath += "/";
objectPath += std::to_string(id);
getCertificateProperties(asyncResp, objectPath, certs::ldapServiceName,
- id, certURL, "LDAP Certificate");
+ std::to_string(id), certURL,
+ "LDAP Certificate");
});
} // requestRoutesLDAPCertificate
/**
@@ -1194,9 +1195,9 @@ inline void requestRoutesTrustStoreCertificateCollection(App& app)
"/redfish/v1/Managers/bmc/Truststore/Certificates/" +
std::to_string(certId);
- getCertificateProperties(asyncResp, objectPath,
- certs::authorityServiceName, certId,
- certURL, "TrustStore Certificate");
+ getCertificateProperties(
+ asyncResp, objectPath, certs::authorityServiceName,
+ std::to_string(certId), certURL, "TrustStore Certificate");
BMCWEB_LOG_DEBUG << "TrustStore certificate install file="
<< certFile->getCertFilePath();
},
@@ -1236,9 +1237,9 @@ inline void requestRoutesTrustStoreCertificate(App& app)
std::string objectPath = certs::authorityObjectPath;
objectPath += "/";
objectPath += std::to_string(id);
- getCertificateProperties(asyncResp, objectPath,
- certs::authorityServiceName, id, certURL,
- "TrustStore Certificate");
+ getCertificateProperties(
+ asyncResp, objectPath, certs::authorityServiceName,
+ std::to_string(id), certURL, "TrustStore Certificate");
});
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/Truststore/Certificates/<str>/")