From 1cddd0fba12c6778a3b24ebd8f5dd8ea0446dff1 Mon Sep 17 00:00:00 2001 From: Seth Schoen Date: Fri, 22 May 2015 14:29:50 -0700 Subject: [PATCH] Use standard plugins interface in config serialization --- letsencrypt/cli.py | 5 +++-- letsencrypt/client.py | 24 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/letsencrypt/cli.py b/letsencrypt/cli.py index 4902459e1..fb9a7244a 100644 --- a/letsencrypt/cli.py +++ b/letsencrypt/cli.py @@ -100,7 +100,7 @@ def run(args, config, plugins): acme, doms = _common_run(args, config, acc, authenticator, installer) # TODO: Handle errors from _common_run? lineage = acme.obtain_and_enroll_certificate(doms, authenticator, - installer) + installer, plugins) if not lineage: return "Certificate could not be obtained" acme.deploy_certificate(doms, lineage) @@ -127,7 +127,8 @@ def auth(args, config, plugins): # TODO: Handle errors from _common_run? acme, doms = _common_run( args, config, acc, authenticator=authenticator, installer=installer) - if not acme.obtain_and_enroll_certificate(doms, authenticator, installer): + if not acme.obtain_and_enroll_certificate(doms, authenticator, installer, + plugins): return "Certificate could not be obtained" diff --git a/letsencrypt/client.py b/letsencrypt/client.py index 06f36570a..ce93f9fe9 100644 --- a/letsencrypt/client.py +++ b/letsencrypt/client.py @@ -156,16 +156,28 @@ class Client(object): return cert_pem, cert_key.pem, chain_pem def obtain_and_enroll_certificate(self, domains, authenticator, installer, - csr=None): + plugins, csr=None): """Get a new certificate for the specified domains using the specified authenticator and installer, and then create a new renewable lineage - containing it.""" + containing it. + + :param list domains: Domains to request. + :param authenticator: The authenticator to use. + :type authenticator: :class:`letsencrypt.interfaces.IAuthenticator` + + :param installer: The installer to use. + :type installer: :class:`letsencrypt.interfaces.IInstaller` + + :param plugins: A PluginsFactory object. + + :param str csr: A preexisting CSR to use with this request. + """ + # TODO: fully identify object types in docstring. cert_pem, privkey, chain_pem = self._obtain_certificate(domains, csr) - # TODO: Add IPlugin.name or use PluginsFactory.find_init instead - # of assuming that each plugin has a .name attribute - self.config.namespace.authenticator = authenticator.name + self.config.namespace.authenticator = plugins.find_init( + authenticator).name if installer is not None: - self.config.namespace.installer = installer.name + self.config.namespace.installer = plugins.find_init(installer).name return storage.RenewableCert.new_lineage(domains[0], cert_pem, privkey, chain_pem, vars(self.config.namespace))