This commit is contained in:
chris 2019-11-15 13:50:08 +01:00
parent ffbcdfab32
commit 8a5dca6247

31
acmetopem.py Normal file
View file

@ -0,0 +1,31 @@
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 or 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)