Cli: Implement Pki Get*Path() helpers

refs #7423
This commit is contained in:
Michael Friedrich 2014-10-21 18:13:08 +02:00
parent a420cf9aa0
commit 4477901123
2 changed files with 43 additions and 1 deletions

View File

@ -31,9 +31,24 @@
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")
@ -242,3 +257,22 @@ int PkiUtility::RequestCertificate(const String& host, const String& port, const
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;
}

View File

@ -33,6 +33,10 @@ namespace icinga
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);
@ -41,8 +45,12 @@ public:
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);
};
}