Skip to content

Domain control validation by email #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cert_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .report import Report
from .smime import SMIME
from .ssl import SSL

from .dcv import DomainControlValidation
__all__ = [
"ACMEAccount", "Admin", "Client", "Domain", "Organization", "PendingError", "Person", "Report", "SMIME", "SSL"
]
23 changes: 23 additions & 0 deletions cert_manager/acme.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,29 @@ def add_domains(self, acme_id, domains):

return result.json()

def get_domains (self, acme_id, **kwargs):
"""List ACME account’s domains

:param int acme_id: The ID of the acme account to list domains
"""
#self._change_api_version("v2")
self.__acc_domains = []
result = self.find_domains(acme_id)
for dom in result:
self.__acc_domains.append(dom)
return self.__acc_domains

@paginate
def find_domains(self, acme_id, **kwargs):

params = {
self._find_params_to_api[param]: kwargs.get(param)
for param in self._find_params_to_api # pylint:disable=consider-using-dict-items
}
url = self._url(f"{acme_id}", "domain")
result = self._client.get(url, params=params)
return result.json()

def remove_domains(self, acme_id, domains):
"""Remove domains from an acme account.

Expand Down
48 changes: 48 additions & 0 deletions cert_manager/dcv.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,27 @@ def start_validation_cname(self, domain: str):

return result.json()

def start_validation_email(self, domain: str):
"""Start Domain Control Validation using Email method.

:param string domain: The domain to validate
:return response: List of valid email addresses
"""

url = self._url("validation", "start", "domain", "email")
data = {"domain": domain}

try:
result = self._client.post(url, data=data)
except HTTPError as exc:
status_code = exc.response.status_code
if status_code == HTTPStatus.BAD_REQUEST:
err_response = exc.response.json()
raise ValueError(err_response["description"]) from exc
raise exc

return result.json()

def submit_validation_cname(self, domain: str):
"""Finish Domain Control Validation using the CNAME method.

Expand All @@ -111,3 +132,30 @@ def submit_validation_cname(self, domain: str):
raise exc

return result.json()

def submit_validation_email(self, domain: str, email: str):
"""Finish Domain Control Validation using the email method.

:param string domain: The domain to validate
:param string email: validation email sent to

:return response: a dictionary containing
status: The status of the validation
orderStatus: The status of the validation request
message: An optional message to help with debugging
"""

url = self._url("validation", "submit", "domain", "email")
data = {"domain": domain,
"email": email}

try:
result = self._client.post(url, data=data)
except HTTPError as exc:
status_code = exc.response.status_code
if status_code == HTTPStatus.BAD_REQUEST:
err_response = exc.response.json()
raise ValueError(err_response["description"]) from exc
raise exc

return result.json()
Loading