Skip to content

Commit 79924bf

Browse files
committed
fix cert bundle renewal & empty cert list (#158).
1 parent 726248d commit 79924bf

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sbin/linuxmuster-renew-certs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# renew self-signed server certs
44
# thomas@linuxmuster.net
5-
# 20250409
5+
# 20250425
66
#
77

88
import datetime
@@ -21,7 +21,7 @@ def usage():
2121
print('Usage: linuxmuster-renew-certs [options]')
2222
print(' [options] may be:')
2323
print(' -c <list>, --certs=<list> : Comma separated list of certificates to be renewed')
24-
print(' ("ca", "server" and/or "firewall" or "all").')
24+
print(' ("ca", "server" and/or "firewall" or "all"). Mandatory.')
2525
print(' -d <#>, --days=<#> : Set number of days (default: 7305).')
2626
print(' -f, --force : Skip security prompt.')
2727
print(' -n, --dry-run : Test only if the firewall certs can be renewed.')
@@ -45,6 +45,7 @@ force = False
4545
reboot = False
4646
days = '7305'
4747
all_list = ['ca', 'server', 'firewall']
48+
cert_list = []
4849

4950

5051
# open logfile
@@ -86,6 +87,10 @@ for o, a in opts:
8687
assert False, "unhandled option"
8788
usage()
8889
sys.exit(1)
90+
if len(cert_list) == 0:
91+
printScript('No certs to renew given (-c)!')
92+
usage()
93+
sys.exit(1)
8994

9095

9196
# get setup values
@@ -214,10 +219,12 @@ def renewCert(item):
214219
if item == 'ca':
215220
pem = cacert
216221
else:
222+
key = ssldir + '/' + name + '.key.pem'
217223
pem = ssldir + '/' + name + '.cert.pem'
218224
csr = ssldir + '/' + name + '.csr'
219225
cnf = ssldir + '/' + name + '_cert_ext.cnf'
220226
chn = ssldir + '/' + name + '.fullchain.pem'
227+
bdl = ssldir + '/' + name + '.cert.bundle.pem'
221228
b64 = pem + '.b64'
222229
b64_old = b64 + '_old'
223230
if name == 'firewall' or name == 'ca':
@@ -235,6 +242,7 @@ def renewCert(item):
235242
subProc('openssl x509 -req -in ' + csr + ' -CA ' + cacert + ' ' + cakey_passin + ' -CAkey '
236243
+ cakey + ' -CAcreateserial -out ' + pem + ' -days ' + days + ' -sha256 -extfile ' + cnf, logfile)
237244
catFiles([pem, cacert], chn)
245+
catFiles([key, pem], bdl)
238246
if name == 'firewall' or name == 'ca':
239247
shutil.copyfile(b64, b64_old)
240248
subProc('base64 -w0 ' + pem + ' > ' + b64, logfile)

0 commit comments

Comments
 (0)