Skip to content

Commit

Permalink
packaging: Renew expiring vmconsole certificates
Browse files Browse the repository at this point in the history
In commit 35e8f51, a check was added
to renew vmconsole certificates when the CA certificate is newer.  But
the certificates are still not renewed if they are expired or close to
being expired.  Let’s fix it by additionally checking for certificate
expiration.

In order to that, we must check the helper certificate file instead of
key.

Bug-Url: https://bugzilla.redhat.com/1988496
  • Loading branch information
mz-pdm authored and ahadas committed Apr 26, 2022
1 parent e6ecc5e commit 096b053
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@

from ovirt_engine_setup import constants as osetupcons
from ovirt_engine_setup.engine import constants as oenginecons
from ovirt_engine_setup.engine_common import pki_utils
from ovirt_engine_setup.vmconsole_proxy_helper import constants as ovmpcons


def _(m):
return gettext.dgettext(message=m, domain='ovirt-engine-setup')


def _refresh_needed(cert_path):
def _refresh_needed(cert_path, check_cert=True):
ca_cert_path = oenginecons.FileLocations.OVIRT_ENGINE_PKI_ENGINE_CA_CERT
return (not os.path.exists(cert_path) or
os.stat(ca_cert_path).st_mtime > os.stat(cert_path).st_mtime)
os.stat(ca_cert_path).st_mtime > os.stat(cert_path).st_mtime or
(check_cert and
pki_utils.cert_expires(pki_utils.x509_load_cert(cert_path))))


@util.export
Expand Down Expand Up @@ -186,7 +189,7 @@ def _setup(self):
ovmpcons.ConfigEnv.VMCONSOLE_PROXY_CONFIG
] and _refresh_needed(
ovmpcons.FileLocations.
OVIRT_ENGINE_PKI_VMCONSOLE_PROXY_HELPER_KEY
OVIRT_ENGINE_PKI_VMCONSOLE_PROXY_HELPER_CERT
)
),
)
Expand Down Expand Up @@ -283,7 +286,8 @@ def _miscPKIEngine(self):
os.path.join(
ovmpcons.FileLocations.VMCONSOLE_PKI_DIR,
'proxy-ssh_host_rsa',
)
),
check_cert=False
)
),
)
Expand Down

0 comments on commit 096b053

Please sign in to comment.