Move dnspython dependency to tests only and only import the dns.resolver when

actually resolving the client.  That way user code that does not call
'simple_verify' for DNS01 challenges does not depend on dnspython.
This commit is contained in:
Wilfried Teiken 2016-01-05 23:58:23 -05:00
parent 4403a78e52
commit fd2709a6fa
2 changed files with 7 additions and 6 deletions

View file

@ -6,8 +6,6 @@ import logging
import socket
from cryptography.hazmat.primitives import hashes
import dns.resolver
import dns.exception
import OpenSSL
import requests
@ -714,8 +712,12 @@ def txt_records_for_name(name):
"""
try:
import dns.resolver
dns_response = dns.resolver.query(name, 'TXT')
except dns.exception.DNSException as error:
logger.error("Unable to resolve %s: %s", name, error)
except ImportError as error:
raise ImportError("Local validation for 'dns-01' challenges requires "
"'dnspython'");
except Exception as error:
logger.error("Unable to resolve %s: %s", name, str(error))
return []
return [txt_rec for rdata in dns_response for txt_rec in rdata.strings]

View file

@ -12,7 +12,6 @@ install_requires = [
'cryptography>=0.8',
# Connection.set_tlsext_host_name (>=0.13), X509Req.get_extensions (>=0.15)
'PyOpenSSL>=0.15',
'dnspython',
'pyrfc3339',
'pytz',
'requests',
@ -76,7 +75,7 @@ setup(
install_requires=install_requires,
extras_require={
'docs': docs_extras,
'testing': testing_extras,
'testing': testing_extras + 'dnspython',
},
entry_points={
'console_scripts': [