From 25c047af283c0b387ff3019fb8e09982335613d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alja=C5=BE=20=C5=A0kof?= Date: Wed, 26 Feb 2025 16:21:07 +0100 Subject: [PATCH] Fix certificate reading In some cases there could be garbage at the beginning or end of the certificate file --- marginaltool | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/marginaltool b/marginaltool index 6eac1c2..9d07700 100755 --- a/marginaltool +++ b/marginaltool @@ -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: