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_dns.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. """DNS 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 DNS server.
  18. It expects that there is some other DNS server configured
  19. to serve all records."""
  20. backend = None
  21. def more_info(self): # pylint: disable=missing-docstring,no-self-use
  22. return self.MORE_INFO
  23. @classmethod
  24. def add_parser_arguments(cls, add):
  25. add("certbot-dns-config", "-f", default="/etc/letsencrypt/certbot-dns.json",
  26. help="Path to certbot-dns configuration file")
  27. def get_chall_pref(self, domain): # pragma: no cover
  28. # pylint: disable=missing-docstring,no-self-use,unused-argument
  29. return [challenges.DNS01]
  30. def __init__(self, *args, **kwargs):
  31. super(Authenticator, self).__init__(*args, **kwargs)
  32. self.full_roots = {}
  33. self.performed = collections.defaultdict(set)
  34. def prepare(self): # pylint: disable=missing-docstring
  35. self.backend = PdnsApiAuthenticator()
  36. conf_path = self.conf("certbot-dns-config")
  37. self.backend.prepare(conf_path)
  38. pass
  39. def perform(self, achalls): # pylint: disable=missing-docstring
  40. return [self._perform_single(achall) for achall in achalls]
  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)