Adding new Traefik format.

This commit is contained in:
Lost Carrier 2020-02-01 23:49:19 +01:00
parent 1caed32e43
commit 415b606f9f

View File

@ -86,6 +86,10 @@ def restartContainerWithDomains(domains):
def createCerts(args): def createCerts(args):
# Read JSON file # Read JSON file
data = json.loads(open(args.certificate).read()) data = json.loads(open(args.certificate).read())
keys = "uppercase"
if args.resolverid:
data = data[args.resolverid]
keys = "lowercase"
# Determine ACME version # Determine ACME version
acme_version = 2 if 'acme-v02' in data['Account']['Registration']['uri'] else 1 acme_version = 2 if 'acme-v02' in data['Account']['Registration']['uri'] else 1
@ -106,10 +110,16 @@ def createCerts(args):
fullchain = c['Certificate']['Certificate'] fullchain = c['Certificate']['Certificate']
sans = c['Domains']['SANs'] sans = c['Domains']['SANs']
elif acme_version == 2: elif acme_version == 2:
name = c['Domain']['Main'] if keys == "uppercase":
privatekey = c['Key'] name = c['Domain']['Main']
fullchain = c['Certificate'] privatekey = c['Key']
sans = c['Domain']['SANs'] fullchain = c['Certificate']
sans = c['Domain']['SANs']
else:
name = c['domain']['main']
privatekey = c['key']
fullchain = c['certificate']
sans = [] #c['domain']['sans'] # not sure what this is - can't find any here...
if (args.include and name not in args.include) or (args.exclude and name in args.exclude): if (args.include and name not in args.include) or (args.exclude and name in args.exclude):
continue continue
@ -210,6 +220,7 @@ if __name__ == "__main__":
description='Extract traefik letsencrypt certificates.') description='Extract traefik letsencrypt certificates.')
parser.add_argument('-c', '--certificate', default='acme.json', type=PathType( parser.add_argument('-c', '--certificate', default='acme.json', type=PathType(
exists=True), help='file that contains the traefik certificates (default acme.json)') exists=True), help='file that contains the traefik certificates (default acme.json)')
parser.add_argument('--resolverid', help='Traefik certificate-resolver-id.')
parser.add_argument('-d', '--directory', default='.', parser.add_argument('-d', '--directory', default='.',
type=PathType(type='dir'), help='output folder') type=PathType(type='dir'), help='output folder')
parser.add_argument('-f', '--flat', action='store_true', parser.add_argument('-f', '--flat', action='store_true',