You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

authenticator.py 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. """DNS plugin."""
  2. import collections
  3. import logging
  4. import zope.interface
  5. from acme import challenges
  6. from certbot import interfaces
  7. from certbot.plugins import common
  8. from certbot_pdns.PdnsApiAuthenticator import PdnsApiAuthenticator
  9. logger = logging.getLogger(__name__)
  10. @zope.interface.implementer(interfaces.IAuthenticator)
  11. @zope.interface.provider(interfaces.IPluginFactory)
  12. class Authenticator(common.Plugin):
  13. """PDNS Authenticator."""
  14. description = "Place challenges in DNS records"
  15. MORE_INFO = """\
  16. Authenticator plugin that performs dns-01 challenge by saving
  17. necessary validation resources to appropriate records in a PowerDNS server."""
  18. backend = None
  19. def more_info(self): # pylint: disable=missing-docstring,no-self-use
  20. return self.MORE_INFO
  21. @classmethod
  22. def add_parser_arguments(cls, add):
  23. add("certbot-pdns-config", default="/etc/letsencrypt/certbot-pdns.json",
  24. help="Path to certbot-pdns configuration file")
  25. def get_chall_pref(self, domain): # pragma: no cover
  26. # pylint: disable=missing-docstring,no-self-use,unused-argument
  27. return [challenges.DNS01]
  28. def __init__(self, *args, **kwargs):
  29. super(Authenticator, self).__init__(*args, **kwargs)
  30. self.full_roots = {}
  31. self.performed = collections.defaultdict(set)
  32. def prepare(self): # pylint: disable=missing-docstring
  33. self.backend = PdnsApiAuthenticator()
  34. conf_path = self.conf("certbot-pdns-config")
  35. self.backend.prepare(conf_path)
  36. pass
  37. def perform(self, achalls): # pylint: disable=missing-docstring
  38. return [self._perform_single(achall) for achall in achalls]
  39. def _perform_single(self, achall):
  40. response, validation = achall.response_and_validation()
  41. return self.backend.perform_single(achall, response, validation)
  42. def cleanup(self, achalls): # pylint: disable=missing-docstring
  43. for achall in achalls:
  44. self.backend.cleanup(achall)