updated pki modules
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2024-04-20 15:59:23 +02:00
parent 53e07a7708
commit 7abec3faa3
2 changed files with 5 additions and 5 deletions

View File

@ -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"]

View File

@ -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]):