mirror of https://github.com/Icinga/icinga2.git
parent
a420cf9aa0
commit
4477901123
|
@ -31,9 +31,24 @@
|
||||||
|
|
||||||
using namespace icinga;
|
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)
|
int PkiUtility::NewCa(void)
|
||||||
{
|
{
|
||||||
String cadir = Application::GetLocalStateDir() + "/lib/icinga2/ca";
|
String cadir = GetLocalCaPath();
|
||||||
|
|
||||||
if (Utility::PathExists(cadir)) {
|
if (Utility::PathExists(cadir)) {
|
||||||
Log(LogCritical, "cli")
|
Log(LogCritical, "cli")
|
||||||
|
@ -242,3 +257,22 @@ int PkiUtility::RequestCertificate(const String& host, const String& port, const
|
||||||
|
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,10 @@ namespace icinga
|
||||||
class PkiUtility
|
class PkiUtility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static String GetPkiPath(void);
|
||||||
|
static String GetLocalCaPath(void);
|
||||||
|
static String GetLocalPkiPath(void);
|
||||||
|
|
||||||
static int NewCa(void);
|
static int NewCa(void);
|
||||||
static int NewCert(const String& cn, const String& keyfile, const String& csrfile, const String& certfile);
|
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 SignCsr(const String& csrfile, const String& certfile);
|
||||||
|
@ -41,8 +45,12 @@ public:
|
||||||
static int RequestCertificate(const String& host, const String& port, const String& keyfile,
|
static int RequestCertificate(const String& host, const String& port, const String& keyfile,
|
||||||
const String& certfile, const String& cafile, const String& trustedfile, const String& ticket);
|
const String& certfile, const String& cafile, const String& trustedfile, const String& ticket);
|
||||||
|
|
||||||
|
static bool CopyCertFile(const String& source, const String& target);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PkiUtility(void);
|
PkiUtility(void);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue