diff options
author | Erica Portnoy <ebportnoy@gmail.com> | 2016-09-22 03:18:52 +0300 |
---|---|---|
committer | Erica Portnoy <ebportnoy@gmail.com> | 2016-09-22 23:55:25 +0300 |
commit | de7fce31dbcd664345082795171d3be6d4b40d16 (patch) | |
tree | 314456a150fc7974a71f8e02a7af52be8d37b73b | |
parent | 151f0ff67fe500c48b57be3dac3d004d8437c973 (diff) |
Make add_server_directives update the passed vhostserver_block_selection
-rw-r--r-- | certbot-nginx/certbot_nginx/configurator.py | 5 | ||||
-rw-r--r-- | certbot-nginx/certbot_nginx/parser.py | 12 |
2 files changed, 10 insertions, 7 deletions
diff --git a/certbot-nginx/certbot_nginx/configurator.py b/certbot-nginx/certbot_nginx/configurator.py index 056d13cf3..7d812b390 100644 --- a/certbot-nginx/certbot_nginx/configurator.py +++ b/certbot-nginx/certbot_nginx/configurator.py @@ -24,7 +24,6 @@ from certbot.plugins import common from certbot_nginx import constants from certbot_nginx import tls_sni_01 -from certbot_nginx import obj from certbot_nginx import parser @@ -348,10 +347,6 @@ class NginxConfigurator(common.Plugin): self.parser.add_server_directives( vhost, ssl_block, replace=False) - vhost.ssl = True - vhost.raw.extend(ssl_block) - vhost.addrs.add(obj.Addr( - '', str(self.config.tls_sni_01_port), True, False)) def get_all_certs_keys(self): """Find all existing keys, certs from configuration. diff --git a/certbot-nginx/certbot_nginx/parser.py b/certbot-nginx/certbot_nginx/parser.py index 971deb273..f858104c2 100644 --- a/certbot-nginx/certbot_nginx/parser.py +++ b/certbot-nginx/certbot_nginx/parser.py @@ -243,7 +243,8 @@ class NginxParser(object): def add_server_directives(self, vhost, directives, replace): - """Add or replace directives in the first server block with names. + """Add or replace directives in the first server block with names, + and update vhost with the new directives. ..note :: If replace is True, this raises a misconfiguration error if the directive does not already exist. @@ -260,7 +261,6 @@ class NginxParser(object): """ filename = vhost.filep - names = vhost.names try: result = self.parsed[filename] for index in vhost.path: @@ -269,6 +269,14 @@ class NginxParser(object): raise errors.MisconfigurationError("Not a server block.") result = result[1] _add_directives(result, directives, replace) + + # update vhost based on new directives + new_server = self._get_included_directives(result) + parsed_server = parse_server(new_server) + vhost.addrs = parsed_server['addrs'] + vhost.ssl = parsed_server['ssl'] + vhost.names = parsed_server['names'] + vhost.raw = new_server except errors.MisconfigurationError as err: raise errors.MisconfigurationError("Problem in %s: %s" % (filename, err.message)) |