From 7abec3faa3b6bda1857631fa5427fd4281d02a76 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sat, 20 Apr 2024 15:59:23 +0200 Subject: [PATCH] updated pki modules --- states/_modules/pki.py | 7 ++++--- states/_states/pki.py | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/states/_modules/pki.py b/states/_modules/pki.py index acc34ec..c27b858 100644 --- a/states/_modules/pki.py +++ b/states/_modules/pki.py @@ -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"] diff --git a/states/_states/pki.py b/states/_states/pki.py index b5de94e..4e050a4 100644 --- a/states/_states/pki.py +++ b/states/_states/pki.py @@ -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]):