email: postfix: use inline map for TLS SNI maps

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2022-02-21 15:04:24 -08:00 committed by James Valleroy
parent 64d0411d6b
commit 265534a6bf
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -49,20 +49,21 @@ _postfix_config = {
def set_postfix_config(primary_domain, all_domains):
"""Set postfix configuration for TLS certificates."""
tls_sni_map = pathlib.Path('/etc/postfix/freedombox-tls-sni.map')
items = []
for domain in all_domains:
items.append(f'{domain}=/etc/postfix/letsencrypt/{domain}/chain.pem')
domain_map = ','.join(items)
config = dict(_postfix_config)
config.update({
'tls_server_sni_maps':
str(tls_sni_map),
f'inline:{{{domain_map}}}',
'smtpd_tls_chain_files':
f'/etc/postfix/letsencrypt/{primary_domain}/chain.pem'
f'/etc/postfix/letsencrypt/{primary_domain}/chain.pem',
'smtpd_tls_cert_file':
''
})
postfix.set_config(config)
content = '# This file is managed by FreedomBox\n'
for domain in all_domains:
content += f'{domain} /etc/postfix/letsencrypt/{domain}/chain.pem\n'
tls_sni_map.write_text(content)
def set_dovecot_config(primary_domain, all_domains):