2021-07-11 17:37:42 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# vim:syntax=python
|
|
|
|
|
|
|
|
import os
|
|
|
|
import requests
|
|
|
|
|
|
|
|
|
|
|
|
def write_file_content(content=None,
|
2021-07-18 10:02:15 +02:00
|
|
|
filename=None):
|
2021-07-11 17:37:42 +02:00
|
|
|
ret = None
|
|
|
|
|
|
|
|
try:
|
2021-07-18 10:02:15 +02:00
|
|
|
with open(filename, "w") as f:
|
2021-07-11 17:37:42 +02:00
|
|
|
ret = f.write(content)
|
|
|
|
except Exception as err:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
def get_file_content(checkfile=None):
|
|
|
|
ret = None
|
|
|
|
|
|
|
|
try:
|
|
|
|
with open(checkfile, 'r') as f:
|
|
|
|
ret = f.read()
|
|
|
|
except FileNotFoundError as err:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
def get_pki_cert(url="http://pki",
|
|
|
|
username=None,
|
|
|
|
password=None,
|
|
|
|
domains=None):
|
|
|
|
ret = None
|
|
|
|
|
|
|
|
try:
|
|
|
|
res = requests.request(method="GET",
|
|
|
|
url=f"{url}/domain/{domains}",
|
|
|
|
auth=(username, password))
|
|
|
|
resj = res.json()
|
|
|
|
|
|
|
|
return resj["certificate"], resj["privatekey"]
|
|
|
|
except Exception as err:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return None, None
|