remove policy config param

This commit is contained in:
Brad Warren 2017-08-09 15:57:19 -07:00
parent 6c5a8423b8
commit a15fe57225
2 changed files with 29 additions and 35 deletions

View file

@ -23,12 +23,10 @@ class Installer(plugins_common.Plugin):
description = "Configure TLS with the Postfix MTA"
def __init__(self,
policy_config,
postfix_dir,
fixup=False):
self.fixup = fixup
self.postfix_dir = postfix_dir
self.policy_config = policy_config
self.policy_file = os.path.join(postfix_dir,
"starttls_everywhere_policy")
self.ca_file = os.path.join(postfix_dir, "starttls_everywhere_CAfile")
@ -133,35 +131,6 @@ class Installer(plugins_common.Plugin):
with open(self.fn, "w") as f:
f.write(self.new_cf)
def set_domainwise_tls_policies(self):
all_acceptable_mxs = self.policy_config.acceptable_mxs
for address_domain, properties in all_acceptable_mxs.items():
mx_list = properties.accept_mx_domains
if len(mx_list) > 1:
logger.warn('Lists of multiple accept-mx-domains not yet '
'supported.')
logger.warn('Using MX {} for {}'.format(mx_list[0],
address_domain)
)
logger.warn('Ignoring: {}'.format(', '.join(mx_list[1:])))
mx_domain = mx_list[0]
mx_policy = self.policy_config.get_tls_policy(mx_domain)
entry = address_domain + " encrypt"
if mx_policy.min_tls_version.lower() == "tlsv1":
entry += " protocols=!SSLv2:!SSLv3"
elif mx_policy.min_tls_version.lower() == "tlsv1.1":
entry += " protocols=!SSLv2:!SSLv3:!TLSv1"
elif mx_policy.min_tls_version.lower() == "tlsv1.2":
entry += " protocols=!SSLv2:!SSLv3:!TLSv1:!TLSv1.1"
else:
logger.warn('Unknown minimum TLS version: {} '.format(
mx_policy.min_tls_version)
)
self.policy_lines.append(entry)
with open(self.policy_file, "w") as f:
f.write("\n".join(self.policy_lines) + "\n")
### Let's Encrypt client IPlugin ###
# https://github.com/letsencrypt/letsencrypt/blob/master/letsencrypt/plugins/common.py#L35
@ -406,6 +375,35 @@ class Installer(plugins_common.Plugin):
def update_CAfile(self):
os.system("cat /usr/share/ca-certificates/mozilla/*.crt > " + self.ca_file)
# def set_domainwise_tls_policies(self):
# all_acceptable_mxs = self.policy_config.acceptable_mxs
# for address_domain, properties in all_acceptable_mxs.items():
# mx_list = properties.accept_mx_domains
# if len(mx_list) > 1:
# logger.warn('Lists of multiple accept-mx-domains not yet '
# 'supported.')
# logger.warn('Using MX {} for {}'.format(mx_list[0],
# address_domain)
# )
# logger.warn('Ignoring: {}'.format(', '.join(mx_list[1:])))
# mx_domain = mx_list[0]
# mx_policy = self.policy_config.get_tls_policy(mx_domain)
# entry = address_domain + " encrypt"
# if mx_policy.min_tls_version.lower() == "tlsv1":
# entry += " protocols=!SSLv2:!SSLv3"
# elif mx_policy.min_tls_version.lower() == "tlsv1.1":
# entry += " protocols=!SSLv2:!SSLv3:!TLSv1"
# elif mx_policy.min_tls_version.lower() == "tlsv1.2":
# entry += " protocols=!SSLv2:!SSLv3:!TLSv1:!TLSv1.1"
# else:
# logger.warn('Unknown minimum TLS version: {} '.format(
# mx_policy.min_tls_version)
# )
# self.policy_lines.append(entry)
# with open(self.policy_file, "w") as f:
# f.write("\n".join(self.policy_lines) + "\n")
def parse_line(line_data):
"""

View file

@ -29,7 +29,6 @@ smtpd_tls_key_file = /etc/letsencrypt/live/www.fubard.org/privkey.pem""")
class TestPostfixConfigGenerator(unittest.TestCase):
def setUp(self):
self.config = None
self.postfix_dir = 'tests/'
def testGetAllNames(self):
@ -37,7 +36,6 @@ class TestPostfixConfigGenerator(unittest.TestCase):
with mock.patch('certbot_postfix.installer.open') as mock_open:
mock_open.return_value = six.StringIO(names_only_config)
postfix_config_gen = installer.Installer(
self.config,
self.postfix_dir,
fixup=True,
)
@ -50,7 +48,6 @@ class TestPostfixConfigGenerator(unittest.TestCase):
with mock.patch('certbot_postfix.installer.open') as mock_open:
mock_open.return_value = six.StringIO(certs_only_config)
postfix_config_gen = installer.Installer(
self.config,
self.postfix_dir,
fixup=True,
)
@ -60,7 +57,6 @@ class TestPostfixConfigGenerator(unittest.TestCase):
with mock.patch('certbot_postfix.installer.open') as mock_open:
mock_open.return_value = six.StringIO(names_only_config)
postfix_config_gen = installer.Installer(
self.config,
self.postfix_dir,
fixup=True,
)