mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 00:35:03 +02:00
Merge pull request #3507 from certbot/only-suggest-valid-names
Only suggest names LE will accept
This commit is contained in:
@@ -281,7 +281,25 @@ class NginxConfigurator(common.Plugin):
|
||||
except (socket.error, socket.herror, socket.timeout):
|
||||
continue
|
||||
|
||||
return all_names
|
||||
return self._get_filtered_names(all_names)
|
||||
|
||||
def _get_filtered_names(self, all_names):
|
||||
"""Removes names that aren't considered valid by Let's Encrypt.
|
||||
|
||||
:param set all_names: all names found in the Nginx configuration
|
||||
|
||||
:returns: all found names that are considered valid by LE
|
||||
:rtype: set
|
||||
|
||||
"""
|
||||
filtered_names = set()
|
||||
for name in all_names:
|
||||
try:
|
||||
filtered_names.add(util.enforce_le_validity(name))
|
||||
except errors.ConfigurationError as error:
|
||||
logger.debug('Not suggesting name "%s"', name)
|
||||
logger.debug(error)
|
||||
return filtered_names
|
||||
|
||||
def _get_snakeoil_paths(self):
|
||||
# TODO: generate only once
|
||||
|
||||
@@ -66,10 +66,8 @@ class NginxConfiguratorTest(util.NginxTest):
|
||||
mock_gethostbyaddr.return_value = ('155.225.50.69.nephoscale.net', [], [])
|
||||
names = self.config.get_all_names()
|
||||
self.assertEqual(names, set(
|
||||
["*.www.foo.com", "somename", "another.alias",
|
||||
"alias", "localhost", ".example.com", r"~^(www\.)?(example|bar)\.",
|
||||
"155.225.50.69.nephoscale.net", "*.www.example.com",
|
||||
"example.*", "www.example.org", "myhost"]))
|
||||
["155.225.50.69.nephoscale.net",
|
||||
"www.example.org", "another.alias"]))
|
||||
|
||||
def test_supported_enhancements(self):
|
||||
self.assertEqual(['redirect', 'staple-ocsp'],
|
||||
|
||||
Reference in New Issue
Block a user