2019-11-15 12:50:08 +00:00
|
|
|
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')
|
|
|
|
|
2019-11-15 13:03:14 +00:00
|
|
|
if not (certbin and keybin):
|
2019-11-15 12:50:08 +00:00
|
|
|
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)
|