Fix certificate reading

In some cases there could be garbage at the beginning or end of the certificate file
This commit is contained in:
Škof, Aljaž 2025-02-26 16:21:07 +01:00
parent cb8bb2531e
commit 25c047af28

View file

@ -33,7 +33,8 @@ def init(args):
args.certfile = config.get(args.url, 'certfile')
if not args.keyfile or not args.certfile:
raise Exception('key or certificate file not specified')
args.cert = ''.join(line.strip() for line in open(args.certfile) if not line.startswith('-----'))
cert = open(args.certfile).read()
args.cert = ''.join(cert[cert.find('-----BEGIN CERTIFICATE-----' + 27):cert.find('-----END CERTIFICATE-----')])
case 'pkcs11':
if not args.id: