This commit is contained in:
James Kasten
2015-08-17 10:40:42 -07:00
parent 62ce3e2fc2
commit dde4951be5
6 changed files with 17 additions and 7 deletions
@@ -482,7 +482,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
logger.debug(msg) logger.debug(msg)
self.save_notes += msg self.save_notes += msg
def prepare_server_https(self, port, temp=False): def prepare_server_https(self, port):
"""Prepare the server for HTTPS. """Prepare the server for HTTPS.
Make sure that the ssl_module is loaded and that the server Make sure that the ssl_module is loaded and that the server
@@ -493,7 +493,10 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
""" """
if "ssl_module" not in self.parser.modules: if "ssl_module" not in self.parser.modules:
logger.info("Loading mod_ssl into Apache Server") logger.info("Loading mod_ssl into Apache Server")
self.enable_mod("ssl", temp) if self.config.func.__name__ == "auth":
self.enable_mod("ssl", temp=True)
else:
self.enable_mod("ssl", temp=False)
# Check for Listen <port> # Check for Listen <port>
# Note: This could be made to also look for ip:443 combo # Note: This could be made to also look for ip:443 combo
@@ -1138,6 +1141,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
if not self._chall_out: if not self._chall_out:
self.revert_challenge_config() self.revert_challenge_config()
self.restart() self.restart()
self.parser.init_modules()
def apache_restart(apache_init_script): def apache_restart(apache_init_script):
@@ -53,7 +53,7 @@ class ApacheDvsni(common.Dvsni):
"le_dvsni_cert_challenge.conf") "le_dvsni_cert_challenge.conf")
def perform(self): def perform(self):
"""Peform a DVSNI challenge.""" """Perform a DVSNI challenge."""
if not self.achalls: if not self.achalls:
return [] return []
# Save any changes to the configuration as a precaution # Save any changes to the configuration as a precaution
@@ -62,7 +62,7 @@ class ApacheDvsni(common.Dvsni):
# Prepare the server for HTTPS # Prepare the server for HTTPS
self.configurator.prepare_server_https( self.configurator.prepare_server_https(
str(self.configurator.config.dvsni_port), True) str(self.configurator.config.dvsni_port))
responses = [] responses = []
@@ -51,7 +51,7 @@ class ApacheParser(object):
# https://httpd.apache.org/docs/2.4/mod/core.html#ifmodule # https://httpd.apache.org/docs/2.4/mod/core.html#ifmodule
# This needs to come before locations are set. # This needs to come before locations are set.
self.modules = set() self.modules = set()
self._init_modules() self.init_modules()
# Set up rest of locations # Set up rest of locations
self.loc.update(self._set_locations()) self.loc.update(self._set_locations())
@@ -60,13 +60,15 @@ class ApacheParser(object):
# Sites-available is not included naturally in configuration # Sites-available is not included naturally in configuration
self._parse_file(os.path.join(self.root, "sites-available") + "/*") self._parse_file(os.path.join(self.root, "sites-available") + "/*")
def _init_modules(self): def init_modules(self):
"""Iterates on the configuration until no new modules are loaded. """Iterates on the configuration until no new modules are loaded.
..todo:: This should be attempted to be done with a binary to avoid ..todo:: This should be attempted to be done with a binary to avoid
the iteration issue. Else... parse and enable mods at same time. the iteration issue. Else... parse and enable mods at same time.
""" """
# Since modules are being initiated... clear existing set.
self.modules = set()
matches = self.find_dir("LoadModule") matches = self.find_dir("LoadModule")
iterator = iter(matches) iterator = iter(matches)
@@ -18,7 +18,7 @@ class ComplexParserTest(util.ParserTest):
self.setup_variables() self.setup_variables()
# This needs to happen after due to setup_variables not being run # This needs to happen after due to setup_variables not being run
# until after # until after
self.parser._init_modules() # pylint: disable=protected-access self.parser.init_modules() # pylint: disable=protected-access
def tearDown(self): def tearDown(self):
shutil.rmtree(self.temp_dir) shutil.rmtree(self.temp_dir)
@@ -22,6 +22,7 @@ class DvsniPerformTest(util.ApacheTest):
config = util.get_apache_configurator( config = util.get_apache_configurator(
self.config_path, self.config_dir, self.work_dir) self.config_path, self.config_dir, self.work_dir)
config.config.dvsni_port = 443 config.config.dvsni_port = 443
config.config.func.__name__ = "auth"
from letsencrypt_apache import dvsni from letsencrypt_apache import dvsni
self.sni = dvsni.ApacheDvsni(config) self.sni = dvsni.ApacheDvsni(config)
@@ -92,6 +92,9 @@ def get_apache_configurator(
config.prepare() config.prepare()
# Simulate a 'run' by default
config.config.func.__name__ = "run"
return config return config