diff --git a/states/_modules/pki.py b/states/_modules/pki.py index 93607c5..be60526 100644 --- a/states/_modules/pki.py +++ b/states/_modules/pki.py @@ -3,9 +3,14 @@ import json import base64 +import ssl from urllib.request import urlopen from urllib.request import Request +ctx = ssl.create_default_context() +ctx.check_hostname = False +ctx.verify_mode = ssl.CERT_NONE + def get_file_content(checkfile=None): try: with open(checkfile, "r") as f: @@ -36,7 +41,7 @@ def get_pki_cert(url="http://pki", authstring = base64.b64encode(f"{username}:{password}".encode()).decode() req.add_header("Authorization", f"Basic {authstring}") jsondata = json.dumps({"domains":domains, "provider": provider}) - res = urlopen(req, jsondata.encode('utf-8')) + res = urlopen(req, jsondata.encode('utf-8'), context=ctx) resj = json.loads(res.read()) return resj[domains[0]]["certificate"], resj[domains[0]]["privatekey"]