import os import sys import json import base64 acmejson_filename = os.environ.get('ACME_FILENAME', "acme.json") acme_store = os.environ.get('ACME_STORE', "leprod") if not len(sys.argv) > 1: print("Usage: acmetopem.py HOST_NAME") sys.exit(1) acmejson = json.load(open(acmejson_filename)) acmestore = acmejson.get(acme_store) certbin = "" keybin = "" for cert in acmestore.get('Certificates'): if not cert.get('domain').get('main') == sys.argv[1]: continue certbin = cert.get('certificate') keybin = cert.get('key') if not (certbin and keybin): print("Cert not found") sys.exit(1) for line in base64.b64decode(keybin).decode('ascii').split('\n'): print(line) for line in base64.b64decode(certbin).decode('ascii').split('\n'): print(line)