diff --git a/main.cpp b/main.cpp index b12c406e..b14c08b3 100644 --- a/main.cpp +++ b/main.cpp @@ -27,7 +27,7 @@ void GenerateHelp(const char *appname) { CUtils::PrintMessage("\t--makepass Generates a password for use in config"); #ifdef HAVE_LIBSSL CUtils::PrintMessage("\t--makepem Generates a pemfile for use with SSL"); - CUtils::PrintMessage("\t--encrypt-pem Encrypts the pemfile"); + CUtils::PrintMessage("\t--encrypt-pem when used along with --makepem, encrypts the private key in the pemfile"); #endif /* HAVE_LIBSSL */ } @@ -138,11 +138,16 @@ int main(int argc, char** argv, char** envp) { if (bMakePem) { CZNC* pZNC = &CZNC::Get(); pZNC->InitDirs(""); - pZNC->WritePemFile(); + pZNC->WritePemFile( bEncPem ); delete pZNC; return 0; } + if( bEncPem && !bMakePem ) { + CUtils::PrintError("--encrypt-pem should be used along with --makepem."); + return 1; + } + #endif /* HAVE_LIBSSL */ if (bMakePass) { CString sHash = CUtils::GetHashPass(); diff --git a/znc.cpp b/znc.cpp index c9e41d97..64191fef 100644 --- a/znc.cpp +++ b/znc.cpp @@ -218,7 +218,7 @@ bool CZNC::WritePidFile(int iPid) { return false; } -bool CZNC::WritePemFile() { +bool CZNC::WritePemFile( bool bEncPem ) { #ifndef HAVE_LIBSSL CUtils::PrintError("ZNC was not compiled with ssl support."); return false; @@ -246,7 +246,7 @@ bool CZNC::WritePemFile() { return false; } - CUtils::GenerateCert(f, false, sHost); + CUtils::GenerateCert(f, bEncPem, sHost); fclose(f); CUtils::PrintStatus(true); diff --git a/znc.h b/znc.h index a9607ac6..cc4e3e4f 100644 --- a/znc.h +++ b/znc.h @@ -124,7 +124,7 @@ public: const CString& GetUserPath() const { if (!CFile::Exists(m_sUserPath)) { CUtils::MakeDir(m_sUserPath); } return m_sUserPath; } CString GetPemLocation() const { return GetZNCPath() + "/znc.pem"; } const CString& GetConfigFile() const { return m_sConfigFile; } - bool WritePemFile(); + bool WritePemFile( bool bEncPem = false ); const CString& GetISpoofFile() const { return m_sISpoofFile; } const CString& GetISpoofFormat() const { return m_sISpoofFormat; } const VCString& GetVHosts() const { return m_vsVHosts; }