mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 08:03:19 +02:00
Rename certbot.le_util to certbot.util
Also rename certbot/tests/le_util_test.py to certbot/tests/util_test.py
This commit is contained in:
+13
-14
@@ -17,7 +17,7 @@ from acme import jose
|
||||
|
||||
from certbot import errors
|
||||
from certbot import interfaces
|
||||
from certbot import le_util
|
||||
from certbot import util
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -37,7 +37,7 @@ def init_save_key(key_size, key_dir, keyname="key-certbot.pem"):
|
||||
:param str keyname: Filename of key
|
||||
|
||||
:returns: Key
|
||||
:rtype: :class:`certbot.le_util.Key`
|
||||
:rtype: :class:`certbot.util.Key`
|
||||
|
||||
:raises ValueError: If unable to generate the key given key_size.
|
||||
|
||||
@@ -50,30 +50,29 @@ def init_save_key(key_size, key_dir, keyname="key-certbot.pem"):
|
||||
|
||||
config = zope.component.getUtility(interfaces.IConfig)
|
||||
# Save file
|
||||
le_util.make_or_verify_dir(key_dir, 0o700, os.geteuid(),
|
||||
config.strict_permissions)
|
||||
key_f, key_path = le_util.unique_file(
|
||||
os.path.join(key_dir, keyname), 0o600)
|
||||
util.make_or_verify_dir(key_dir, 0o700, os.geteuid(),
|
||||
config.strict_permissions)
|
||||
key_f, key_path = util.unique_file(os.path.join(key_dir, keyname), 0o600)
|
||||
with key_f:
|
||||
key_f.write(key_pem)
|
||||
|
||||
logger.info("Generating key (%d bits): %s", key_size, key_path)
|
||||
|
||||
return le_util.Key(key_path, key_pem)
|
||||
return util.Key(key_path, key_pem)
|
||||
|
||||
|
||||
def init_save_csr(privkey, names, path, csrname="csr-certbot.pem"):
|
||||
"""Initialize a CSR with the given private key.
|
||||
|
||||
:param privkey: Key to include in the CSR
|
||||
:type privkey: :class:`certbot.le_util.Key`
|
||||
:type privkey: :class:`certbot.util.Key`
|
||||
|
||||
:param set names: `str` names to include in the CSR
|
||||
|
||||
:param str path: Certificate save directory.
|
||||
|
||||
:returns: CSR
|
||||
:rtype: :class:`certbot.le_util.CSR`
|
||||
:rtype: :class:`certbot.util.CSR`
|
||||
|
||||
"""
|
||||
config = zope.component.getUtility(interfaces.IConfig)
|
||||
@@ -82,16 +81,16 @@ def init_save_csr(privkey, names, path, csrname="csr-certbot.pem"):
|
||||
must_staple=config.must_staple)
|
||||
|
||||
# Save CSR
|
||||
le_util.make_or_verify_dir(path, 0o755, os.geteuid(),
|
||||
util.make_or_verify_dir(path, 0o755, os.geteuid(),
|
||||
config.strict_permissions)
|
||||
csr_f, csr_filename = le_util.unique_file(
|
||||
csr_f, csr_filename = util.unique_file(
|
||||
os.path.join(path, csrname), 0o644)
|
||||
csr_f.write(csr_pem)
|
||||
csr_f.close()
|
||||
|
||||
logger.info("Creating CSR: %s", csr_filename)
|
||||
|
||||
return le_util.CSR(csr_filename, csr_der, "der")
|
||||
return util.CSR(csr_filename, csr_der, "der")
|
||||
|
||||
|
||||
# Lower level functions
|
||||
@@ -187,7 +186,7 @@ def import_csr_file(csrfile, data):
|
||||
:param str data: contents of the CSR file
|
||||
|
||||
:returns: (`OpenSSL.crypto.FILETYPE_PEM` or `OpenSSL.crypto.FILETYPE_ASN1`,
|
||||
le_util.CSR object representing the CSR,
|
||||
util.CSR object representing the CSR,
|
||||
list of domains requested in the CSR)
|
||||
:rtype: tuple
|
||||
|
||||
@@ -200,7 +199,7 @@ def import_csr_file(csrfile, data):
|
||||
logger.debug("CSR parse error (form=%s, typ=%s):", form, typ)
|
||||
logger.debug(traceback.format_exc())
|
||||
continue
|
||||
return typ, le_util.CSR(file=csrfile, data=data, form=form), domains
|
||||
return typ, util.CSR(file=csrfile, data=data, form=form), domains
|
||||
raise errors.Error("Failed to parse CSR file: {0}".format(csrfile))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user