This commit is contained in:
parent
53e07a7708
commit
7abec3faa3
@ -32,11 +32,12 @@ def get_pki_cert(url="http://pki",
|
|||||||
username=None,
|
username=None,
|
||||||
password=None,
|
password=None,
|
||||||
domains=None):
|
domains=None):
|
||||||
req = Request(method="GET",
|
req = Request(method="POST",
|
||||||
url=f"{url}/domain/{domains}")
|
url=f"{url}/cert",
|
||||||
|
headers={"Content-Type":"application/json"})
|
||||||
authstring = base64.b64encode(f"{username}:{password}".encode()).decode()
|
authstring = base64.b64encode(f"{username}:{password}".encode()).decode()
|
||||||
req.add_header("Authorization", f"Basic {authstring}")
|
req.add_header("Authorization", f"Basic {authstring}")
|
||||||
res = urlopen(req)
|
res = urlopen(req, json.dumps(domains))
|
||||||
resj = json.loads(res.read())
|
resj = json.loads(res.read())
|
||||||
|
|
||||||
return resj["certificate"], resj["privatekey"]
|
return resj["certificate"], resj["privatekey"]
|
||||||
|
@ -21,7 +21,6 @@ def fetched(name=None,
|
|||||||
|
|
||||||
currentcert = None
|
currentcert = None
|
||||||
currentkey = None
|
currentkey = None
|
||||||
domain_concat = ",".join(domains)
|
|
||||||
|
|
||||||
currentcert = __salt__['pki.get_file_content'](checkfile=certfile)
|
currentcert = __salt__['pki.get_file_content'](checkfile=certfile)
|
||||||
currentkey = __salt__['pki.get_file_content'](checkfile=keyfile)
|
currentkey = __salt__['pki.get_file_content'](checkfile=keyfile)
|
||||||
@ -30,7 +29,7 @@ def fetched(name=None,
|
|||||||
newcert, newkey = __salt__['pki.get_pki_cert'](url=url,
|
newcert, newkey = __salt__['pki.get_pki_cert'](url=url,
|
||||||
username=username,
|
username=username,
|
||||||
password=password,
|
password=password,
|
||||||
domains=domain_concat)
|
domains=domains)
|
||||||
newfullcert = f"{newcert}\n\n{newkey}"
|
newfullcert = f"{newcert}\n\n{newkey}"
|
||||||
|
|
||||||
if all([newcert,newkey,newfullcert]):
|
if all([newcert,newkey,newfullcert]):
|
||||||
|
Loading…
Reference in New Issue
Block a user