2021-04-07 12:49:21 +02:00
|
|
|
#!/usr/bin/python3
|
2021-01-24 20:04:03 +01:00
|
|
|
# vim:syntax=python
|
|
|
|
|
|
|
|
import os
|
|
|
|
import requests
|
|
|
|
|
2021-01-30 13:06:11 +01:00
|
|
|
URL=os.environ.get("URL")
|
|
|
|
DOMAINS=os.environ.get("DOMAINS")
|
|
|
|
FULLCERTFILE=os.environ.get("FULLCERTFILE")
|
|
|
|
KEYFILE=os.environ.get("KEYFILE")
|
|
|
|
USERNAME=os.environ.get("USERNAME")
|
|
|
|
PASSWORD=os.environ.get("PASSWORD")
|
2022-10-01 20:10:31 +02:00
|
|
|
MERGE=eval(os.environ.get("MERGE"))
|
2021-01-24 20:04:03 +01:00
|
|
|
|
|
|
|
def main():
|
2022-10-01 20:10:31 +02:00
|
|
|
res = requests.request(method="GET",
|
|
|
|
url=f"{URL}/domain/{DOMAINS}",
|
|
|
|
auth=(USERNAME, PASSWORD))
|
2021-01-24 20:04:03 +01:00
|
|
|
resj = res.json()
|
|
|
|
|
|
|
|
try:
|
2021-01-30 13:06:11 +01:00
|
|
|
if "certificate" in resj.keys():
|
|
|
|
with open(FULLCERTFILE, "w") as fcf:
|
|
|
|
fcf.write(resj["certificate"])
|
2021-01-24 20:04:03 +01:00
|
|
|
|
2021-01-30 13:06:11 +01:00
|
|
|
if "privatekey" in resj.keys():
|
|
|
|
with open(KEYFILE, "w") as fkf:
|
|
|
|
fkf.write(resj["privatekey"])
|
2021-01-24 20:04:03 +01:00
|
|
|
except Exception as e:
|
2021-01-30 13:06:11 +01:00
|
|
|
print(e)
|
2021-01-24 20:04:03 +01:00
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|