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