mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 16:19:13 +02:00
Update Client.obtain_* docs, simplify obtain_certificate() rtype.
This commit is contained in:
+21
-11
@@ -130,11 +130,14 @@ class Client(object):
|
|||||||
Internal function with precondition that `domains` are
|
Internal function with precondition that `domains` are
|
||||||
consistent with identifiers present in the `csr`.
|
consistent with identifiers present in the `csr`.
|
||||||
|
|
||||||
:param .le_util.CSR csr: Certificate Signing Request must
|
:param list domains: Domain names.
|
||||||
contain requested domains, the key used to generate this CSR
|
:param .le_util.CSR csr: DER-encoded Certificate Signing
|
||||||
can be different than self.authkey.
|
Request. The key used to generate this CSR can be different
|
||||||
|
than `authkey`.
|
||||||
|
|
||||||
:returns: Certificate Resource and certificate chain.
|
:returns: `.CertificateResource` and certificate chain (as
|
||||||
|
returned by `.fetch_chain`).
|
||||||
|
:rtype: tuple
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if self.auth_handler is None:
|
if self.auth_handler is None:
|
||||||
@@ -158,7 +161,12 @@ class Client(object):
|
|||||||
def obtain_certificate_from_csr(self, csr):
|
def obtain_certificate_from_csr(self, csr):
|
||||||
"""Obtain certficiate from CSR.
|
"""Obtain certficiate from CSR.
|
||||||
|
|
||||||
:param .le_util.CSR csr: Certificate Signing Request.
|
:param .le_util.CSR csr: DER-encoded Certificate Signing
|
||||||
|
Request.
|
||||||
|
|
||||||
|
:returns: `.CertificateResource` and certificate chain (as
|
||||||
|
returned by `.fetch_chain`).
|
||||||
|
:rtype: tuple
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self._obtain_certificate(
|
return self._obtain_certificate(
|
||||||
@@ -169,13 +177,15 @@ class Client(object):
|
|||||||
def obtain_certificate(self, domains):
|
def obtain_certificate(self, domains):
|
||||||
"""Obtains a certificate from the ACME server.
|
"""Obtains a certificate from the ACME server.
|
||||||
|
|
||||||
:meth:`.register` must be called before :meth:`.obtain_certificate`
|
`.register` must be called before `.obtain_certificate`
|
||||||
|
|
||||||
:param set domains: domains to get a certificate
|
:param set domains: domains to get a certificate
|
||||||
|
|
||||||
:returns: Certificate, private key, and certificate chain (all
|
:returns: `.CertificateResource`, certificate chain (as
|
||||||
PEM-encoded).
|
returned by `.fetch_chain`), and newly generated private key
|
||||||
:rtype: `tuple` of `str`
|
(`.le_util.Key`) and DER-encoded Certificate Signing Request
|
||||||
|
(`.le_util.CSR`).
|
||||||
|
:rtype: tuple
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Create CSR from names
|
# Create CSR from names
|
||||||
@@ -183,7 +193,7 @@ class Client(object):
|
|||||||
self.config.rsa_key_size, self.config.key_dir)
|
self.config.rsa_key_size, self.config.key_dir)
|
||||||
csr = crypto_util.init_save_csr(key, domains, self.config.cert_dir)
|
csr = crypto_util.init_save_csr(key, domains, self.config.cert_dir)
|
||||||
|
|
||||||
return key, csr, self._obtain_certificate(domains, csr)
|
return self._obtain_certificate(domains, csr) + (key, csr)
|
||||||
|
|
||||||
def obtain_and_enroll_certificate(
|
def obtain_and_enroll_certificate(
|
||||||
self, domains, authenticator, installer, plugins):
|
self, domains, authenticator, installer, plugins):
|
||||||
@@ -207,7 +217,7 @@ class Client(object):
|
|||||||
not be obtained.
|
not be obtained.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
key, _, (certr, chain) = self.obtain_certificate(domains)
|
certr, chain, key, _ = self.obtain_certificate(domains)
|
||||||
|
|
||||||
# TODO: remove this dirty hack
|
# TODO: remove this dirty hack
|
||||||
self.config.namespace.authenticator = plugins.find_init(
|
self.config.namespace.authenticator = plugins.find_init(
|
||||||
|
|||||||
@@ -74,8 +74,7 @@ class ClientTest(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.client.obtain_certificate(domains),
|
self.client.obtain_certificate(domains),
|
||||||
(mock.sentinel.key, csr, (
|
(mock.sentinel.certr, mock.sentinel.chain, mock.sentinel.key, csr))
|
||||||
mock.sentinel.certr, mock.sentinel.chain)))
|
|
||||||
|
|
||||||
mock_crypto_util.init_save_key.assert_called_once_with(
|
mock_crypto_util.init_save_key.assert_called_once_with(
|
||||||
self.config.rsa_key_size, self.config.key_dir)
|
self.config.rsa_key_size, self.config.key_dir)
|
||||||
|
|||||||
Reference in New Issue
Block a user