Last active
March 27, 2023 13:43
-
-
Save leeyc0/a8eaf0c50638d2cdb6707ad0377764d1 to your computer and use it in GitHub Desktop.
patch certbot_dns_ovh to follow CNAME
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- certbot_dns_ovh/_internal/dns_ovh.py.orig 2023-03-27 12:48:43.913613478 +0000 | |
+++ certbot_dns_ovh/_internal/dns_ovh.py 2023-03-27 13:20:36.651115194 +0000 | |
@@ -7,6 +7,8 @@ | |
from lexicon.providers import ovh | |
from requests import HTTPError | |
+import dns.resolver | |
+ | |
from certbot import errors | |
from certbot.plugins import dns_common | |
from certbot.plugins import dns_common_lexicon | |
@@ -29,6 +31,8 @@ | |
def __init__(self, *args: Any, **kwargs: Any) -> None: | |
super().__init__(*args, **kwargs) | |
self.credentials: Optional[CredentialsConfiguration] = None | |
+ self.resolver = dns.resolver.Resolver(configure = False) | |
+ self.resolver.nameservers = ["8.8.8.8"] | |
@classmethod | |
def add_parser_arguments(cls, add: Callable[..., None], | |
@@ -54,12 +58,14 @@ | |
.format(TOKEN_URL), | |
} | |
) | |
- | |
+ | |
def _perform(self, domain: str, validation_name: str, validation: str) -> None: | |
- self._get_ovh_client().add_txt_record(domain, validation_name, validation) | |
+ validation_name = self.resolver.canonical_name(validation_name).to_text().rstrip(".") | |
+ self._get_ovh_client().add_txt_record(validation_name, validation_name, validation) | |
def _cleanup(self, domain: str, validation_name: str, validation: str) -> None: | |
- self._get_ovh_client().del_txt_record(domain, validation_name, validation) | |
+ validation_name = self.resolver.canonical_name(validation_name).to_text().rstrip(".") | |
+ self._get_ovh_client().del_txt_record(validation_name, validation_name, validation) | |
def _get_ovh_client(self) -> "_OVHLexiconClient": | |
if not self.credentials: # pragma: no cover |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment