mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 16:12:09 +02:00
Move eula to registration
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
"""ACME protocol client class and helper functions."""
|
"""ACME protocol client class and helper functions."""
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
import M2Crypto
|
import M2Crypto
|
||||||
import zope.component
|
import zope.component
|
||||||
@@ -62,8 +63,7 @@ class Client(object):
|
|||||||
|
|
||||||
# TODO: Allow for other alg types besides RS256
|
# TODO: Allow for other alg types besides RS256
|
||||||
self.network = network2.Network(
|
self.network = network2.Network(
|
||||||
"https://%s/acme/new-reg" % config.server,
|
"https://" + config.server, jwk.JWKRSA.load(self.account.key.pem))
|
||||||
jwk.JWKRSA.load(self.account.key.pem))
|
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
@@ -79,14 +79,18 @@ class Client(object):
|
|||||||
self.account = self.network.register_from_account(self.account)
|
self.account = self.network.register_from_account(self.account)
|
||||||
if self.account.terms_of_service:
|
if self.account.terms_of_service:
|
||||||
if not self.config.tos:
|
if not self.config.tos:
|
||||||
|
# TODO: Replace with self.account.terms_of_service
|
||||||
|
eula = pkg_resources.resource_string("letsencrypt", "EULA")
|
||||||
agree = zope.component.getUtility(interfaces.IDisplay).yesno(
|
agree = zope.component.getUtility(interfaces.IDisplay).yesno(
|
||||||
self.account.terms_of_service, "Agree", "Cancel")
|
eula, "Agree", "Cancel")
|
||||||
else:
|
else:
|
||||||
agree = True
|
agree = True
|
||||||
|
|
||||||
if agree:
|
if agree:
|
||||||
self.account.regr = self.network.agree_to_tos(self.account.regr)
|
self.account.regr = self.network.agree_to_tos(self.account.regr)
|
||||||
# TODO: Handle case where user doesn't agree
|
else:
|
||||||
|
# What is the proper response here...
|
||||||
|
raise errors.LetsEncryptClientError("Must agree to TOS")
|
||||||
|
|
||||||
self.account.save()
|
self.account.save()
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,9 @@ import mock
|
|||||||
import os
|
import os
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import zope.component
|
|
||||||
|
|
||||||
from letsencrypt.acme import messages2
|
from letsencrypt.acme import messages2
|
||||||
|
|
||||||
from letsencrypt.client import configuration
|
from letsencrypt.client import configuration
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ def create_parser():
|
|||||||
config_help = lambda name: interfaces.IConfig[name].__doc__
|
config_help = lambda name: interfaces.IConfig[name].__doc__
|
||||||
|
|
||||||
add("-d", "--domains", metavar="DOMAIN", nargs="+")
|
add("-d", "--domains", metavar="DOMAIN", nargs="+")
|
||||||
add("-s", "--server", default="www.letsencrypt-demo.org/acme/new-reg",
|
add("-s", "--server",
|
||||||
|
default="www.letsencrypt-demo.org/acme/new-reg",
|
||||||
help=config_help("server"))
|
help=config_help("server"))
|
||||||
|
|
||||||
# TODO: we should generate the list of choices from the set of
|
# TODO: we should generate the list of choices from the set of
|
||||||
@@ -194,9 +195,6 @@ def main(): # pylint: disable=too-many-branches, too-many-statements
|
|||||||
if acc is None:
|
if acc is None:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if not args.tos:
|
|
||||||
display_eula()
|
|
||||||
|
|
||||||
all_auths = init_auths(config)
|
all_auths = init_auths(config)
|
||||||
logging.debug('Initialized authenticators: %s', all_auths.keys())
|
logging.debug('Initialized authenticators: %s', all_auths.keys())
|
||||||
try:
|
try:
|
||||||
@@ -235,7 +233,11 @@ def main(): # pylint: disable=too-many-branches, too-many-statements
|
|||||||
# but this code should be safe on all environments.
|
# but this code should be safe on all environments.
|
||||||
cert_file = None
|
cert_file = None
|
||||||
if auth is not None:
|
if auth is not None:
|
||||||
acme.register()
|
if acc.regr is None:
|
||||||
|
try:
|
||||||
|
acme.register()
|
||||||
|
except errors.LetsEncryptClientError:
|
||||||
|
sys.exit(0)
|
||||||
cert_file, chain_file = acme.obtain_certificate(doms)
|
cert_file, chain_file = acme.obtain_certificate(doms)
|
||||||
if installer is not None and cert_file is not None:
|
if installer is not None and cert_file is not None:
|
||||||
acme.deploy_certificate(doms, acc.key, cert_file, chain_file)
|
acme.deploy_certificate(doms, acc.key, cert_file, chain_file)
|
||||||
@@ -243,14 +245,6 @@ def main(): # pylint: disable=too-many-branches, too-many-statements
|
|||||||
acme.enhance_config(doms, args.redirect)
|
acme.enhance_config(doms, args.redirect)
|
||||||
|
|
||||||
|
|
||||||
def display_eula():
|
|
||||||
"""Displays the end user agreement."""
|
|
||||||
eula = pkg_resources.resource_string("letsencrypt", "EULA")
|
|
||||||
if not zope.component.getUtility(interfaces.IDisplay).yesno(
|
|
||||||
eula, "Agree", "Cancel"):
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
def read_file(filename):
|
def read_file(filename):
|
||||||
"""Returns the given file's contents with universal new line support.
|
"""Returns the given file's contents with universal new line support.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user