Merge pull request #3507 from certbot/only-suggest-valid-names

Only suggest names LE will accept
This commit is contained in:
Peter Eckersley
2016-09-22 14:23:19 -07:00
committed by GitHub
4 changed files with 83 additions and 6 deletions
+19 -1
View File
@@ -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'],