From 26ffcadba9a71eff2340774b8a8bfd6c605c4879 Mon Sep 17 00:00:00 2001 From: "George T. Gougoudis" Date: Wed, 21 Sep 2016 17:37:28 +0300 Subject: [PATCH] Quick hack for TypeError raise in dnspython --- management/ssl_certificates.py | 18 ++++++++++++++++-- management/status_checks.py | 9 ++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/management/ssl_certificates.py b/management/ssl_certificates.py index c49443b9..083da476 100755 --- a/management/ssl_certificates.py +++ b/management/ssl_certificates.py @@ -238,8 +238,22 @@ def get_certificates_to_provision(env, show_extended_problems=True, force_domain except Exception as e: problems[domain] = "DNS isn't configured properly for this domain: DNS lookup had an error: %s." % str(e) return False - if len(response) != 1 or str(response[0]) != value: - problems[domain] = "Domain control validation cannot be performed for this domain because DNS points the domain to another machine (%s %s)." % (rtype, ", ".join(str(r) for r in response)) + + if len(response) == 1: + try: + response_str = str(response[0]) + except TypeError: + response_str = response[0].to_text().decode('utf8') + if len(response) != 1 or response_str != value: + addresses = list() + for r in response: + try: + addresses.append(str(r).rstrip('.')) + except TypeError: + addresses.append(r.to_text().decode('utf8').rstrip('.')) + + err_txt = ", ".join(sorted(addresses)) + problems[domain] = "Domain control validation cannot be performed for this domain because DNS points the domain to another machine (%s %s)." % (rtype, err_txt) return False return True diff --git a/management/status_checks.py b/management/status_checks.py index 527495c7..fa8927d7 100755 --- a/management/status_checks.py +++ b/management/status_checks.py @@ -680,7 +680,14 @@ def query_dns(qname, rtype, nxdomain='[Not Set]', at=None): # periods from responses since that's how qnames are encoded in DNS but is # confusing for us. The order of the answers doesn't matter, so sort so we # can compare to a well known order. - return "; ".join(sorted(str(r).rstrip('.') for r in response)) + addresses = list() + for r in response: + try: + addresses.append(str(r).rstrip('.')) + except TypeError: + addresses.append(r.to_text().decode('utf8').rstrip('.')) + + return "; ".join(sorted(addresses)) def check_ssl_cert(domain, rounded_time, ssl_certificates, env, output): # Check that TLS certificate is signed.