From 77493d6e1a98752db21eda6dbee7d871cc9b45c7 Mon Sep 17 00:00:00 2001 From: Erica Portnoy Date: Thu, 11 Jan 2018 14:09:08 -0800 Subject: [PATCH 1/4] properly test for port number --- certbot-nginx/certbot_nginx/configurator.py | 2 +- certbot-nginx/certbot_nginx/http_01.py | 2 +- certbot-nginx/certbot_nginx/tests/util.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/certbot-nginx/certbot_nginx/configurator.py b/certbot-nginx/certbot_nginx/configurator.py index f5b231ba3..89e67dd04 100644 --- a/certbot-nginx/certbot_nginx/configurator.py +++ b/certbot-nginx/certbot_nginx/configurator.py @@ -412,7 +412,7 @@ class NginxConfigurator(common.Installer): Rank by how well these match target_name. :param str target_name: The name to match - :param str port: port number + :param str port: port number as a string :returns: list of dicts containing the vhost, the matching name, and the numerical rank :rtype: list diff --git a/certbot-nginx/certbot_nginx/http_01.py b/certbot-nginx/certbot_nginx/http_01.py index 4f565f2ca..3f814f4a7 100644 --- a/certbot-nginx/certbot_nginx/http_01.py +++ b/certbot-nginx/certbot_nginx/http_01.py @@ -94,7 +94,7 @@ class NginxHttp01(common.ChallengePerformer): """ vhost = self.configurator.choose_redirect_vhost(achall.domain, - self.configurator.config.http01_port, create_if_no_match=True) + '%i' % self.configurator.config.http01_port, create_if_no_match=True) validation = achall.validation(achall.account_key) validation_path = self._get_validation_path(achall) diff --git a/certbot-nginx/certbot_nginx/tests/util.py b/certbot-nginx/certbot_nginx/tests/util.py index 7b32d8e82..ad1af2b96 100644 --- a/certbot-nginx/certbot_nginx/tests/util.py +++ b/certbot-nginx/certbot_nginx/tests/util.py @@ -64,6 +64,7 @@ def get_nginx_configurator( in_progress_dir=os.path.join(backups, "IN_PROGRESS"), server="https://acme-server.org:443/new", tls_sni_01_port=5001, + http01_port=80 ), name="nginx", version=version) From ffe8870b9b41c0f4fb5113524e9807f53cea81b7 Mon Sep 17 00:00:00 2001 From: Erica Portnoy Date: Thu, 11 Jan 2018 14:20:36 -0800 Subject: [PATCH 2/4] use domains that have matching addresses --- certbot-nginx/certbot_nginx/configurator.py | 1 + certbot-nginx/certbot_nginx/tests/http_01_test.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/certbot-nginx/certbot_nginx/configurator.py b/certbot-nginx/certbot_nginx/configurator.py index 89e67dd04..46d341049 100644 --- a/certbot-nginx/certbot_nginx/configurator.py +++ b/certbot-nginx/certbot_nginx/configurator.py @@ -394,6 +394,7 @@ class NginxConfigurator(common.Installer): vhost = self._select_best_name_match(matches) if not vhost: if create_if_no_match: + import ipdb; ipdb.set_trace() vhost = self._vhost_from_duplicated_default(target_name) else: # No matches. Raise a misconfiguration error. diff --git a/certbot-nginx/certbot_nginx/tests/http_01_test.py b/certbot-nginx/certbot_nginx/tests/http_01_test.py index 9da57d896..0f764e92e 100644 --- a/certbot-nginx/certbot_nginx/tests/http_01_test.py +++ b/certbot-nginx/certbot_nginx/tests/http_01_test.py @@ -30,7 +30,7 @@ class HttpPerformTest(util.NginxTest): token=b"\xba\xa9\xda? Date: Thu, 11 Jan 2018 14:23:00 -0800 Subject: [PATCH 3/4] remove debugger --- certbot-nginx/certbot_nginx/configurator.py | 1 - 1 file changed, 1 deletion(-) diff --git a/certbot-nginx/certbot_nginx/configurator.py b/certbot-nginx/certbot_nginx/configurator.py index 46d341049..89e67dd04 100644 --- a/certbot-nginx/certbot_nginx/configurator.py +++ b/certbot-nginx/certbot_nginx/configurator.py @@ -394,7 +394,6 @@ class NginxConfigurator(common.Installer): vhost = self._select_best_name_match(matches) if not vhost: if create_if_no_match: - import ipdb; ipdb.set_trace() vhost = self._vhost_from_duplicated_default(target_name) else: # No matches. Raise a misconfiguration error. From 265afaf7a090f74a20760de3198639cd22fc8688 Mon Sep 17 00:00:00 2001 From: Erica Portnoy Date: Thu, 11 Jan 2018 14:27:43 -0800 Subject: [PATCH 4/4] remove access_log and error_log cruft that wasn't being executed --- certbot-nginx/certbot_nginx/http_01.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/certbot-nginx/certbot_nginx/http_01.py b/certbot-nginx/certbot_nginx/http_01.py index 3f814f4a7..1f1e37891 100644 --- a/certbot-nginx/certbot_nginx/http_01.py +++ b/certbot-nginx/certbot_nginx/http_01.py @@ -101,16 +101,6 @@ class NginxHttp01(common.ChallengePerformer): location_directive = [[['location', ' ', '=', ' ', validation_path], [['default_type', ' ', 'text/plain'], ['return', ' ', '200', ' ', validation]]]] - log_directives = [# access and error logs necessary for - # integration testing (non-root) - ['access_log', ' ', os.path.join( - self.configurator.config.work_dir, 'access.log')], - ['error_log', ' ', os.path.join( - self.configurator.config.work_dir, 'error.log')] - ] self.configurator.parser.add_server_directives(vhost, location_directive, replace=False) - if False: # TODO: detect if we're integration testing - self.configurator.parser.add_server_directives(vhost, - log_directives, replace=False)