letsencrypt: Don't try to obtain certificates for .local domains

Replace the check for ignoring .onion domains with a check that ignore any
domain type that can't have certificates.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-08-20 09:24:42 -07:00 committed by James Valleroy
parent 855a99cc21
commit 3ba7e961c4
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -29,6 +29,7 @@ from plinth import app as app_module
from plinth import cfg, menu from plinth import cfg, menu
from plinth.errors import ActionError from plinth.errors import ActionError
from plinth.modules import names from plinth.modules import names
from plinth.modules.names.components import DomainType
from plinth.signals import domain_added, domain_removed, post_module_loading from plinth.signals import domain_added, domain_removed, post_module_loading
from plinth.utils import format_lazy from plinth.utils import format_lazy
@ -151,7 +152,7 @@ def certificate_delete(domain):
def on_domain_added(sender, domain_type='', name='', description='', def on_domain_added(sender, domain_type='', name='', description='',
services=None, **kwargs): services=None, **kwargs):
"""Obtain a certificate for the new domain""" """Obtain a certificate for the new domain"""
if domain_type == 'domain-type-tor': if not DomainType.get(domain_type).can_have_certificate:
return False return False
# Check if a cert if already available # Check if a cert if already available
@ -173,6 +174,9 @@ def on_domain_added(sender, domain_type='', name='', description='',
def on_domain_removed(sender, domain_type, name='', **kwargs): def on_domain_removed(sender, domain_type, name='', **kwargs):
"""Revoke Let's Encrypt certificate for the removed domain""" """Revoke Let's Encrypt certificate for the removed domain"""
if not DomainType.get(domain_type).can_have_certificate:
return False
try: try:
# Revoking certs during tests or empty names isn't expected to succeed # Revoking certs during tests or empty names isn't expected to succeed
if sender != 'test' and name: if sender != 'test' and name: