Allow same certificate with multiple projects (same domain)

This commit is contained in:
Matej Bačo 2022-03-23 13:31:35 +00:00
parent 154379c848
commit 213215bffa

View file

@ -98,6 +98,23 @@ class CertificatesV1 extends Worker
&& isset($certificate['issueDate'])
&& (($certificate['issueDate'] + ($expiry)) > \time())
) { // Check last issue time
// Update document anyway, if needed
// This occurs when a cert is already generated because a different project is using the domain
// By updating here we ensure all domains has certificateId assigned (share same certificate document)
if(!isset($document['certificateId'])) {
$certificate = new Document(\array_merge($document, [
'updated' => \time(),
'certificateId' => $certificate->getId(),
]));
$certificate = $dbForConsole->updateDocument('domains', $certificate->getId(), $certificate);
if(!$certificate) {
throw new Exception('Failed saving domain to DB');
}
}
throw new Exception('Renew isn\'t required');
}