diff options
author | Jiaqing Zhao <jiaqing.zhao@intel.com> | 2022-04-13 12:01:57 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-04-15 18:13:08 +0300 |
commit | 90d2d1e887e68c70f8e5923eb69c3c9356dae547 (patch) | |
tree | ac7ecadb55fd81beef111d3a98c6593fcaafaa3c /redfish-core/lib | |
parent | 6f581ec3584cd9b4556a114d30f7a39c63ec64ec (diff) | |
download | bmcweb-90d2d1e887e68c70f8e5923eb69c3c9356dae547.tar.xz |
CertificateService: Enhance error handling for ReplaceCertificate
Current implementation of the ReplaceCertificate API always returns
ResourceNotFound if any error occurs when calling DBus, regardless of
whether the certificate to be replaced exists or not. This patch checks
the error code and only return ResourceNotFound when the object path
does not exist, otherwise returns InternalError.
Tested:
* Replace HTTPS certificate at /redfish/v1/Managers/bmc/NetworkProtocol
/HTTPS/Certificates/0 (Invalid URL) returns ResourceNotFound.
* Replace HTTPS certificate at /redfish/v1/Managers/bmc/NetworkProtocol
/HTTPS/Certificates/1 with CertificateString not containing private
key returns InternalError.
Change-Id: I67f6014c3856c192b4141e6a92f173a9a8c8189e
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
Diffstat (limited to 'redfish-core/lib')
-rw-r--r-- | redfish-core/lib/certificate_service.hpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp index 9bea9b98c4..ccf5e9ae09 100644 --- a/redfish-core/lib/certificate_service.hpp +++ b/redfish-core/lib/certificate_service.hpp @@ -3,6 +3,7 @@ #include <app.hpp> #include <boost/convert.hpp> #include <boost/convert/strtol.hpp> +#include <boost/system/linux_error.hpp> #include <dbus_utility.hpp> #include <query.hpp> #include <registries/privilege_registry.hpp> @@ -780,8 +781,14 @@ inline void requestRoutesCertificateActionsReplaceCertificate(App& app) if (ec) { BMCWEB_LOG_ERROR << "DBUS response error: " << ec; - messages::resourceNotFound(asyncResp->res, name, - std::to_string(id)); + if (ec.value() == + boost::system::linux_error::bad_request_descriptor) + { + messages::resourceNotFound(asyncResp->res, name, + std::to_string(id)); + return; + } + messages::internalError(asyncResp->res); return; } getCertificateProperties(asyncResp, objectPath, service, id, |