Add support to upload CA certificate
Added support to upload CA certificates in
/etc/ssl/certs path. Curently scope is limited to one
certificate and any new upload is going to override the
existing CA certificate.
Change-Id: I9cc60accf6aae4d8123e5f86d618effe33d68d53
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
diff --git a/certs_manager.hpp b/certs_manager.hpp
index 8601c64..1ca4f1a 100644
--- a/certs_manager.hpp
+++ b/certs_manager.hpp
@@ -18,13 +18,17 @@
// Supported Types.
static constexpr auto SERVER = "server";
static constexpr auto CLIENT = "client";
+static constexpr auto AUTHORITY = "authority";
using Create = sdbusplus::xyz::openbmc_project::Certs::server::Install;
using Delete = sdbusplus::xyz::openbmc_project::Object::server::Delete;
using Ifaces = sdbusplus::server::object::object<Create, Delete>;
-using InstallFunc = std::function<void()>;
+using InstallFunc = std::function<void(const std::string&)>;
using InputType = std::string;
+// for placeholders
+using namespace std::placeholders;
+
class Manager : public Ifaces
{
public:
@@ -59,9 +63,11 @@
certPath(std::move(certPath))
{
typeFuncMap[SERVER] =
- std::bind(&phosphor::certs::Manager::serverInstall, this);
+ std::bind(&phosphor::certs::Manager::serverInstallHelper, this, _1);
typeFuncMap[CLIENT] =
- std::bind(&phosphor::certs::Manager::clientInstall, this);
+ std::bind(&phosphor::certs::Manager::clientInstallHelper, this, _1);
+ typeFuncMap[AUTHORITY] = std::bind(
+ &phosphor::certs::Manager::authorityInstallHelper, this, _1);
}
/** @brief Implementation for Install
@@ -78,11 +84,20 @@
void delete_() override;
private:
- /** @brief Client certificate Installation helper function **/
- virtual void clientInstall();
+ /** @brief Client certificate Installation helper function
+ * @param[in] path - Certificate key file path.
+ */
+ virtual void clientInstallHelper(const std::string& filePath);
- /** @brief Server certificate Installation helper function **/
- virtual void serverInstall();
+ /** @brief Server certificate Installation helper function
+ * @param[in] path - Certificate key file path.
+ */
+ virtual void serverInstallHelper(const std::string& filePath);
+
+ /** @brief Authority certificate Installation helper function
+ * @param[in] path - Certificate key file path.
+ */
+ virtual void authorityInstallHelper(const std::string& filePath);
/** @brief systemd unit reload or reset helper function
* Reload if the unit supports it and use a restart otherwise.