key_path = f'{daemon_spec.host}/grafana_key'
cert = self.mgr.get_store(cert_path)
pkey = self.mgr.get_store(key_path)
- is_empty_certificate = not (cert and pkey)
+ certs_present = (cert and pkey)
is_valid_certificate = False
(org, cn) = (None, None)
- if not is_empty_certificate:
+ if certs_present:
try:
(org, cn) = get_cert_issuer_info(cert)
verify_tls(cert, pkey)
# certificate is not valid, to avoid overwriting user generated
# certificates we only re-generate in case of self signed certificates
# that were originally generated by cephadm or in case cert/key are empty.
- if is_empty_certificate or (org == 'Ceph' and cn == 'cephadm'):
+ if not certs_present or (org == 'Ceph' and cn == 'cephadm'):
logger.info('Regenerating cephadm self-signed grafana TLS certificates')
cert, pkey = create_self_signed_cert('Ceph', daemon_spec.host)
self.mgr.set_store(cert_path, cert)