Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

authenticator.py 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. responses = [self._perform_single(achall) for achall in achalls]
  39. self.backend.wait_for_propagation(achalls)
  40. return responses
  41. def _perform_single(self, achall):
  42. response, validation = achall.response_and_validation()
  43. return self.backend.perform_single(achall, response, validation)
  44. def cleanup(self, achalls): # pylint: disable=missing-docstring
  45. for achall in achalls:
  46. self.backend.cleanup(achall)