mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
ApiListener#Start(): auto-renew CA on its owner
otherwise it would expire.
This commit is contained in:
parent
36a08b0497
commit
bc778116e9
@ -248,7 +248,12 @@ void ApiListener::Start(bool runtimeCreated)
|
|||||||
|
|
||||||
if (Utility::PathExists(GetIcingaCADir() + "/ca.key")) {
|
if (Utility::PathExists(GetIcingaCADir() + "/ca.key")) {
|
||||||
RenewOwnCert();
|
RenewOwnCert();
|
||||||
m_RenewOwnCertTimer->OnTimerExpired.connect([this](const Timer * const&) { RenewOwnCert(); });
|
RenewCA();
|
||||||
|
|
||||||
|
m_RenewOwnCertTimer->OnTimerExpired.connect([this](const Timer * const&) {
|
||||||
|
RenewOwnCert();
|
||||||
|
RenewCA();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
m_RenewOwnCertTimer->OnTimerExpired.connect([this](const Timer * const&) {
|
m_RenewOwnCertTimer->OnTimerExpired.connect([this](const Timer * const&) {
|
||||||
JsonRpcConnection::SendCertificateRequest(nullptr, nullptr, String());
|
JsonRpcConnection::SendCertificateRequest(nullptr, nullptr, String());
|
||||||
@ -329,6 +334,31 @@ void ApiListener::RenewOwnCert()
|
|||||||
UpdateSSLContext();
|
UpdateSSLContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApiListener::RenewCA()
|
||||||
|
{
|
||||||
|
auto certPath (GetCaDir() + "/ca.crt");
|
||||||
|
auto cert (GetX509Certificate(certPath));
|
||||||
|
|
||||||
|
if (IsCaUptodate(cert.get())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log(LogInformation, "ApiListener")
|
||||||
|
<< "Our CA will expire soon, but we own it. Renewing.";
|
||||||
|
|
||||||
|
cert = RenewCert(cert, true);
|
||||||
|
|
||||||
|
if (!cert) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto certStr (CertificateToString(cert));
|
||||||
|
|
||||||
|
AtomicFile::Write(GetDefaultCaPath(), 0644, certStr);
|
||||||
|
AtomicFile::Write(certPath, 0644, certStr);
|
||||||
|
UpdateSSLContext();
|
||||||
|
}
|
||||||
|
|
||||||
void ApiListener::Stop(bool runtimeDeleted)
|
void ApiListener::Stop(bool runtimeDeleted)
|
||||||
{
|
{
|
||||||
m_ApiPackageIntegrityTimer->Stop(true);
|
m_ApiPackageIntegrityTimer->Stop(true);
|
||||||
|
@ -227,6 +227,7 @@ private:
|
|||||||
void SyncLocalZoneDirs() const;
|
void SyncLocalZoneDirs() const;
|
||||||
void SyncLocalZoneDir(const Zone::Ptr& zone) const;
|
void SyncLocalZoneDir(const Zone::Ptr& zone) const;
|
||||||
void RenewOwnCert();
|
void RenewOwnCert();
|
||||||
|
void RenewCA();
|
||||||
|
|
||||||
void SendConfigUpdate(const JsonRpcConnection::Ptr& aclient);
|
void SendConfigUpdate(const JsonRpcConnection::Ptr& aclient);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user