ghostwheel42's suggestions

master
Florent Daigniere 3 years ago
parent ab35492589
commit f9869b1d79

@ -38,17 +38,13 @@ def format_for_nginx(fullchain, output):
""" We may want to strip ISRG Root X1 out """ """ We may want to strip ISRG Root X1 out """
if not os.path.exists(fullchain): if not os.path.exists(fullchain):
return return
certs = [] split = '-----END CERTIFICATE-----\n'
with open(fullchain, 'r') as pem: with open(fullchain, 'r') as pem:
cert = '' certs = [f'{cert}{split}' for cert in pem.read().split(split) if cert]
for line in pem: if len(certs)>2 and os.getenv('LETSENCRYPT_SHORTCHAIN'):
cert += line del certs[-1]
if '-----END CERTIFICATE-----' in line:
certs += [cert]
cert = ''
with open(output, 'w') as pem: with open(output, 'w') as pem:
for cert in certs[:-1] if len(certs)>2 and os.getenv('LETSENCRYPT_SHORTCHAIN', default="False") else certs: pem.write(''.join(certs))
pem.write(cert)
if args['TLS_FLAVOR'] in ['letsencrypt', 'mail-letsencrypt']: if args['TLS_FLAVOR'] in ['letsencrypt', 'mail-letsencrypt']:
format_for_nginx('/certs/letsencrypt/live/mailu/fullchain.pem', '/certs/letsencrypt/live/mailu/nginx-chain.pem') format_for_nginx('/certs/letsencrypt/live/mailu/fullchain.pem', '/certs/letsencrypt/live/mailu/nginx-chain.pem')

Loading…
Cancel
Save