'api setup' must not override existing certificate and api-users.conf file

fixes #10560
This commit is contained in:
Michael Friedrich 2015-11-08 14:19:06 +01:00
parent e6159ca86a
commit b7f923dd01
1 changed files with 12 additions and 0 deletions

View File

@ -83,6 +83,12 @@ bool ApiSetupUtility::SetupMasterCertificates(const String& cn)
String key = pki_path + "/" + cn + ".key";
String csr = pki_path + "/" + cn + ".csr";
if (Utility::PathExists(key)) {
Log(LogInformation, "cli")
<< "Private key file '" << key << "' already existing, skipping.";
return true;
}
Log(LogInformation, "cli")
<< "Generating new CSR in '" << csr << "'.";
@ -153,6 +159,12 @@ bool ApiSetupUtility::SetupMasterApiUser(void)
String api_password = RandomString(8);
String apiuserspath = GetConfdPath() + "/api-users.conf";
if (Utility::PathExists(apiuserspath)) {
Log(LogInformation, "cli")
<< "API user config file '" << apiuserspath << "' already existing, skipping.";
return true;
}
Log(LogInformation, "cli")
<< "Adding new ApiUser '" << api_username << "' in '" << apiuserspath << "'.";