From 30dfb6a1a97fa8f3c4dceefa76b6bb01daab2293 Mon Sep 17 00:00:00 2001 From: Jakub Warmuz Date: Sat, 27 Jun 2015 08:37:29 +0000 Subject: [PATCH] letsencrypt_nginx: respect IConfig.dvsni_port (partially fixes #479). --- letsencrypt_nginx/configurator.py | 4 ++-- letsencrypt_nginx/dvsni.py | 3 ++- letsencrypt_nginx/tests/configurator_test.py | 12 ++++++------ letsencrypt_nginx/tests/util.py | 1 + 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/letsencrypt_nginx/configurator.py b/letsencrypt_nginx/configurator.py index 852ff82ac..3e7de7322 100644 --- a/letsencrypt_nginx/configurator.py +++ b/letsencrypt_nginx/configurator.py @@ -288,7 +288,7 @@ class NginxConfigurator(common.Plugin): """ snakeoil_cert, snakeoil_key = self._get_snakeoil_paths() - ssl_block = [['listen', '443 ssl'], + ssl_block = [['listen', '{0} ssl'.format(self.config.dvsni_port)], ['ssl_certificate', snakeoil_cert], ['ssl_certificate_key', snakeoil_key], ['include', self.parser.loc["ssl_options"]]] @@ -296,7 +296,7 @@ class NginxConfigurator(common.Plugin): vhost.filep, vhost.names, ssl_block) vhost.ssl = True vhost.raw.extend(ssl_block) - vhost.addrs.add(obj.Addr('', '443', True, False)) + vhost.addrs.add(obj.Addr('', str(self.config.dvsni_port), True, False)) def get_all_certs_keys(self): """Find all existing keys, certs from configuration. diff --git a/letsencrypt_nginx/dvsni.py b/letsencrypt_nginx/dvsni.py index 53221614f..756783217 100644 --- a/letsencrypt_nginx/dvsni.py +++ b/letsencrypt_nginx/dvsni.py @@ -47,7 +47,8 @@ class NginxDvsni(common.Dvsni): self.configurator.save() addresses = [] - default_addr = "443 default_server ssl" + default_addr = "{0} default_server ssl".format( + self.configurator.config.dvsni_port) for achall in self.achalls: vhost = self.configurator.choose_vhost(achall.domain) diff --git a/letsencrypt_nginx/tests/configurator_test.py b/letsencrypt_nginx/tests/configurator_test.py index 48d71e27d..b2c1fc7f6 100644 --- a/letsencrypt_nginx/tests/configurator_test.py +++ b/letsencrypt_nginx/tests/configurator_test.py @@ -57,7 +57,7 @@ class NginxConfiguratorTest(util.NginxTest): filep = self.config.parser.abs_path('sites-enabled/example.com') self.config.parser.add_server_directives( filep, set(['.example.com', 'example.*']), - [['listen', '443 ssl']]) + [['listen', '5001 ssl']]) self.config.save() # pylint: disable=protected-access @@ -66,7 +66,7 @@ class NginxConfiguratorTest(util.NginxTest): ['listen', '127.0.0.1'], ['server_name', '.example.com'], ['server_name', 'example.*'], - ['listen', '443 ssl']]]], + ['listen', '5001 ssl']]]], parsed[0]) def test_choose_vhost(self): @@ -100,7 +100,7 @@ class NginxConfiguratorTest(util.NginxTest): nginx_conf = self.config.parser.abs_path('nginx.conf') example_conf = self.config.parser.abs_path('sites-enabled/example.com') - # Get the default 443 vhost + # Get the default SSL vhost self.config.deploy_cert( "www.example.com", "example/cert.pem", "example/key.pem") @@ -116,7 +116,7 @@ class NginxConfiguratorTest(util.NginxTest): ['listen', '127.0.0.1'], ['server_name', '.example.com'], ['server_name', 'example.*'], - ['listen', '443 ssl'], + ['listen', '5001 ssl'], ['ssl_certificate', 'example/cert.pem'], ['ssl_certificate_key', 'example/key.pem'], ['include', @@ -131,7 +131,7 @@ class NginxConfiguratorTest(util.NginxTest): [['location', '/'], [['root', 'html'], ['index', 'index.html index.htm']]], - ['listen', '443 ssl'], + ['listen', '5001 ssl'], ['ssl_certificate', '/etc/nginx/cert.pem'], ['ssl_certificate_key', '/etc/nginx/key.pem'], ['include', @@ -142,7 +142,7 @@ class NginxConfiguratorTest(util.NginxTest): nginx_conf = self.config.parser.abs_path('nginx.conf') example_conf = self.config.parser.abs_path('sites-enabled/example.com') - # Get the default 443 vhost + # Get the default SSL vhost self.config.deploy_cert( "www.example.com", "example/cert.pem", "example/key.pem") diff --git a/letsencrypt_nginx/tests/util.py b/letsencrypt_nginx/tests/util.py index 77c2ea198..414a2f315 100644 --- a/letsencrypt_nginx/tests/util.py +++ b/letsencrypt_nginx/tests/util.py @@ -53,6 +53,7 @@ def get_nginx_configurator( backup_dir=backups, temp_checkpoint_dir=os.path.join(work_dir, "temp_checkpoints"), in_progress_dir=os.path.join(backups, "IN_PROGRESS"), + dvsni_port=5001, ), name="nginx", version=version)