letsencrypt: Handle cert setup when an app wants all domains

Currently, when domains is for an app's LE component is set as '*'. Calling
setup_certificates() results in copying certificate for the '*' domain instead
copying certificates for each of the domains on the system. Fix this by
implementing a special case where certificates are copied for all domains that
can have certificates.

Tests:

- Implement and run unit tests.

- Certificates are copied to /etc/{postfix,dovecot}/letsencrypt/ when email
server uses LE components with '*' for domains parameter.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2021-12-14 18:22:41 -05:00
1 parent 84f12d8633
commit aff62d4d85
2 files changed
+40

No files matched your search

+7
View File
@@ -9,6 +9,7 @@ import pathlib
import threading
from plinth import actions, app
from plinth.modules.names.components import DomainName
logger = logging.getLogger(__name__)
@@ -151,6 +152,12 @@ class LetsEncrypt(app.FollowerComponent):
if not app_domains:
app_domains = self.domains
if app_domains == '*':
# Setup for all domains and not just ones that LE can obtain
# certificate for. This allows the domains that can't have LE
# certificate to work with self-signed certificates.
app_domains = DomainName.list_names()
domains, status = self._get_letsencrypt_domains()
if self.should_copy_certificates: