def _determine_account(config): """Determine which account to use. In order to make the renewer (configuration de/serialization) happy, if ``config.account`` is ``None``, it will be updated based on the user input. Same for ``config.email``. :param argparse.Namespace config: CLI arguments :param letsencrypt.interface.IConfig config: Configuration object :param .AccountStorage account_storage: Account storage. :returns: Account and optionally ACME client API (biproduct of new registration). :rtype: `tuple` of `letsencrypt.account.Account` and `acme.client.Client` """ account_storage = account.AccountFileStorage(config) acme = None if config.account is not None: acc = account_storage.load(config.account) else: accounts = account_storage.find_all() if len(accounts) > 1: acc = display_ops.choose_account(accounts) elif len(accounts) == 1: acc = accounts[0] else: # no account registered yet if config.email is None and not config.register_unsafely_without_email: config.namespace.email = display_ops.get_email() def _tos_cb(regr): if config.tos: return True msg = ("Please read the Terms of Service at {0}. You " "must agree in order to register with the ACME " "server at {1}".format(regr.terms_of_service, config.server)) obj = zope.component.getUtility(interfaces.IDisplay) return obj.yesno(msg, "Agree", "Cancel", cli_flag="--agree-tos") try: acc, acme = client.register(config, account_storage, tos_cb=_tos_cb) except errors.MissingCommandlineFlag: raise except errors.Error as error: logger.debug(error, exc_info=True) raise errors.Error( "Unable to register an account with ACME server") config.namespace.account = acc.id return acc, acme
def _determine_account(args, config): """Determine which account to use. In order to make the renewer (configuration de/serialization) happy, if ``args.account`` is ``None``, it will be updated based on the user input. Same for ``args.email``. :param argparse.Namespace args: CLI arguments :param letsencrypt.interface.IConfig config: Configuration object :param .AccountStorage account_storage: Account storage. :returns: Account and optionally ACME client API (biproduct of new registration). :rtype: `tuple` of `letsencrypt.account.Account` and `acme.client.Client` """ account_storage = account.AccountFileStorage(config) acme = None if args.account is not None: acc = account_storage.load(args.account) else: accounts = account_storage.find_all() if len(accounts) > 1: acc = display_ops.choose_account(accounts) elif len(accounts) == 1: acc = accounts[0] else: # no account registered yet if args.email is None: args.email = display_ops.get_email() if not args.email: # get_email might return "" args.email = None def _tos_cb(regr): if args.tos: return True msg = ("Please read the Terms of Service at {0}. You " "must agree in order to register with the ACME " "server at {1}".format( regr.terms_of_service, config.server)) return zope.component.getUtility(interfaces.IDisplay).yesno( msg, "Agree", "Cancel") try: acc, acme = client.register( config, account_storage, tos_cb=_tos_cb) except errors.Error as error: logger.debug(error, exc_info=True) raise errors.Error( "Unable to register an account with ACME server") args.account = acc.id return acc, acme
def perform_registration(acme, config): """ Actually register new account, trying repeatedly if there are email problems :param .IConfig config: Client configuration. :param acme.client.Client client: ACME client object. :returns: Registration Resource. :rtype: `acme.messages.RegistrationResource` :raises .UnexpectedUpdate: """ try: return acme.register(messages.NewRegistration.from_data(email=config.email)) except messages.Error as e: if e.typ == "urn:acme:error:invalidEmail": config.namespace.email = display_ops.get_email(more=True, invalid=True) return perform_registration(acme, config) else: raise
def _call(cls): from letsencrypt.display.ops import get_email return get_email()
def _call(cls, **kwargs): from letsencrypt.display.ops import get_email return get_email(**kwargs)