updated pki module

This commit is contained in:
Paul 2025-10-04 01:04:50 +02:00
parent a483cf7c74
commit 181808b7f4

View File

@ -3,9 +3,14 @@
import json import json
import base64 import base64
import ssl
from urllib.request import urlopen from urllib.request import urlopen
from urllib.request import Request 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): def get_file_content(checkfile=None):
try: try:
with open(checkfile, "r") as f: 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() authstring = base64.b64encode(f"{username}:{password}".encode()).decode()
req.add_header("Authorization", f"Basic {authstring}") req.add_header("Authorization", f"Basic {authstring}")
jsondata = json.dumps({"domains":domains, "provider": provider}) 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()) resj = json.loads(res.read())
return resj[domains[0]]["certificate"], resj[domains[0]]["privatekey"] return resj[domains[0]]["certificate"], resj[domains[0]]["privatekey"]