diff --git a/client-webserver/configurator.py b/client-webserver/configurator.py index 2ded392dd..f72b64d66 100644 --- a/client-webserver/configurator.py +++ b/client-webserver/configurator.py @@ -2,6 +2,7 @@ import augeas import subprocess import re import os +import socket BASE_DIR = "/etc/apache2/" @@ -107,7 +108,24 @@ class Configurator(object): return v return None - + def get_all_names(self): + """ + Returns all names found in the Apache Configuration + Returns all ServerNames, ServerAliases, and reverse DNS entries for + virtual host addresses + """ + all_names = [] + for v in self.vhosts: + all_names.extend(v.names) + for a in v.addrs: + a_tup = a.split(":") + try: + socket.inet_aton(a_tup[0]) + all_names.append(socket.gethostbyaddr(a_tup[0])[0]) + except (socket.error, socket.herror, socket.timeout): + continue + + return all_names def __add_servernames(self, host): """ @@ -337,7 +355,8 @@ class Configurator(object): Enables mod_ssl TODO: TEST """ - subprocess.call(["sudo", "a2enmod", "ssl"]) + # Use check_output so the command will finish before reloading the server + subprocess.check_output(["sudo", "a2enmod", "ssl"]) subprocess.call(["sudo", "/etc/init.d/apache2", "reload"]) """ a_conf = BASE_DIR + "mods-available/ssl.conf" @@ -451,9 +470,12 @@ def main(): for v in config.vhosts: for a in v.addrs: print "Address:",a, "- Is name vhost?", config.is_name_vhost(a) - + + print config.get_all_names() + config.parse_file("/etc/apache2/ports_test.conf") + #for m in config.aug.match("/augeas/load/Httpd/incl"): # print m, config.aug.get(m) #config.add_name_vhost("example2.com:443") diff --git a/client-webserver/sni_challenge.py b/client-webserver/sni_challenge.py index 7894b0d1c..cb3be103f 100644 --- a/client-webserver/sni_challenge.py +++ b/client-webserver/sni_challenge.py @@ -61,7 +61,7 @@ def getConfigText(nonce, ip_addr, key): """ configText = " \n \ -Servername " + nonce + ".chocolate \n \ +ServerName " + nonce + ".chocolate \n \ UseCanonicalName on \n \ SSLStrictSNIVHostCheck on \n \ \n \