using namespace icinga;
+String PkiUtility::GetPkiPath(void)
+{
+ return Application::GetSysconfDir() + "/icinga2/pki";
+}
+
+String PkiUtility::GetLocalCaPath(void)
+{
+ return Application::GetLocalStateDir() + "/lib/icinga2/ca";
+}
+
+String PkiUtility::GetLocalPkiPath(void)
+{
+ return Application::GetLocalStateDir() + "/lib/icinga2/pki";
+}
+
int PkiUtility::NewCa(void)
{
- String cadir = Application::GetLocalStateDir() + "/lib/icinga2/ca";
+ String cadir = GetLocalCaPath();
if (Utility::PathExists(cadir)) {
Log(LogCritical, "cli")
return 0;
}
+
+
+bool PkiUtility::CopyCertFile(const String& source, const String& target)
+{
+ /*
+ if (PathExists(target)) {
+ Log(LogWarning, "Utility")
+ << "Target file '" << target << "' already exists.";
+ return false;
+ }
+
+ std::ifstream ifs(source, std::ios::binary);
+ std::ofstream ofs(target, std::ios::binary);
+
+ ofs << ifs.rdbuf();
+ */
+
+ return true;
+}
class PkiUtility
{
public:
+ static String GetPkiPath(void);
+ static String GetLocalCaPath(void);
+ static String GetLocalPkiPath(void);
+
static int NewCa(void);
static int NewCert(const String& cn, const String& keyfile, const String& csrfile, const String& certfile);
static int SignCsr(const String& csrfile, const String& certfile);
static int RequestCertificate(const String& host, const String& port, const String& keyfile,
const String& certfile, const String& cafile, const String& trustedfile, const String& ticket);
+ static bool CopyCertFile(const String& source, const String& target);
+
private:
PkiUtility(void);
+
+
};
}