mirror of https://github.com/Icinga/icinga2.git
Log messages now use CN, file permissions fixed, ca remove now will not remove CSR's that have already been signed.
This commit is contained in:
parent
6aa2e0c36b
commit
d95feb4950
|
@ -5,8 +5,8 @@ set(cli_SOURCES
|
|||
apisetupcommand.cpp apisetupcommand.hpp
|
||||
apisetuputility.cpp apisetuputility.hpp
|
||||
calistcommand.cpp calistcommand.hpp
|
||||
carestorecommand.cpp carestorecommand.hpp
|
||||
caremovecommand.cpp caremovecommand.hpp
|
||||
carestorecommand.cpp carestorecommand.hpp
|
||||
casigncommand.cpp casigncommand.hpp
|
||||
clicommand.cpp clicommand.hpp
|
||||
consolecommand.cpp consolecommand.hpp
|
||||
|
|
|
@ -61,12 +61,25 @@ int CARemoveCommand::Run(const boost::program_options::variables_map& vm, const
|
|||
<< "No request exists for fingerprint '" << ap[0] << "'.";
|
||||
return 1;
|
||||
}
|
||||
Utility::SaveJsonFile(ApiListener::GetCertificateRequestsDir() + "/" + ap[0] + ".removed", 700, Utility::LoadJsonFile(requestFile));
|
||||
|
||||
Dictionary::Ptr request = Utility::LoadJsonFile(requestFile);
|
||||
std::shared_ptr<X509> certRequest = StringToCertificate(request->Get("cert_request"));
|
||||
|
||||
if (!certRequest) {
|
||||
Log(LogCritical, "cli", "Certificate request is invalid. Could not parse X.509 certificate for the 'cert_request' attribute.");
|
||||
return 1;
|
||||
}
|
||||
if (request->Contains("cert_response")) {
|
||||
Log(LogCritical, "cli", "Certificate request already signed, you cannot remove it.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Utility::SaveJsonFile(ApiListener::GetCertificateRequestsDir() + "/" + ap[0] + ".removed", 0600, request);
|
||||
if(remove(requestFile.CStr()) != 0)
|
||||
return 1;
|
||||
|
||||
Log(LogInformation, "cli")
|
||||
<< "Certificate " << ap[0] << " removed.";
|
||||
<< "Certificate for CN " << GetCertificateCN(certRequest) << " removed.";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -61,12 +61,21 @@ int CARestoreCommand::Run(const boost::program_options::variables_map& vm, const
|
|||
<< "No removed request exists for fingerprint '" << ap[0] << "'.";
|
||||
return 1;
|
||||
}
|
||||
Utility::SaveJsonFile(ApiListener::GetCertificateRequestsDir() + "/" + ap[0] + ".json", 700, Utility::LoadJsonFile(requestFile));
|
||||
|
||||
Dictionary::Ptr request = Utility::LoadJsonFile(requestFile);
|
||||
std::shared_ptr<X509> certRequest = StringToCertificate(request->Get("cert_request"));
|
||||
|
||||
if (!certRequest) {
|
||||
Log(LogCritical, "cli", "Certificate request is invalid. Could not parse X.509 certificate for the 'cert_request' attribute.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Utility::SaveJsonFile(ApiListener::GetCertificateRequestsDir() + "/" + ap[0] + ".json", 0600, request);
|
||||
if(remove(requestFile.CStr()) != 0)
|
||||
return 1;
|
||||
|
||||
Log(LogInformation, "cli")
|
||||
<< "Certificate " << ap[0] << " restored, you can now sign it using:\n"
|
||||
<< "Certificate " << GetCertificateCN(certRequest) << " restored, you can now sign it using:\n"
|
||||
<< "\"icinga2 ca sign " << ap[0] << "\"";
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue