]> granicus.if.org Git - icinga2/commitdiff
Cli: Implement Pki Get*Path() helpers
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 21 Oct 2014 16:13:08 +0000 (18:13 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Tue, 21 Oct 2014 16:15:05 +0000 (18:15 +0200)
refs #7423

lib/cli/pkiutility.cpp
lib/cli/pkiutility.hpp

index e630578e8b35dc4cdc0624d06f7e64a2b98eb70b..5c6e1c9dd1be08b0893884091149c365d26d4ba0 100644 (file)
 
 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;
+}
index fae86330cc8500c4ede84ce2705d3418629dfeb5..0e965ab6ff05c56265b5c6d1d9554351c40f0f43 100644 (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);
+
+
 };
 
 }