From effd532e54e277660b1b17f64ea4b81d9d31c4bd Mon Sep 17 00:00:00 2001 From: swee Date: Wed, 15 Jan 2025 21:51:42 -0800 Subject: [PATCH] Update server.py --- server.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server.py b/server.py index 426702b..0e79adf 100644 --- a/server.py +++ b/server.py @@ -33,19 +33,21 @@ def loadcert_backend(): if 'privkey' not in request.files: return "Invalid request. (privkey is missing!)" cert = request.files['cert'].read() - privkey = request.files['privkey'].read() + privkey = request.files['privkey'] + certt = cert.read() + privkeyy = privkey.read() if cert.filename == '' or privkey.filename == '': return "Please upload a certificate and private key." if allowed_file(cert.filename) and allowed_file(privkey.filename): for i in os.listdir(homefolder + "/certs/"): thisname = "-".join(i.split("-")[:-1]) - if (open(homefolder + "/certs/" + thisname + "-privkey.pem").read() == privkey) and (open(homefolder + "/certs/" + thisname + "-chain.pem").read() == cert): + if (open(homefolder + "/certs/" + thisname + "-privkey.pem").read() == privkeyy) and (open(homefolder + "/certs/" + thisname + "-chain.pem").read() == certt): resp = make_response('The certificate seems to already exist, loading the used file.

Go home

') resp.set_cookie('certname',thisname) return resp random_name = str(uuid.uuid4()) - open(homefolder + "/certs/" + random_name + "-chain.pem", 'w').write(cert) - open(homefolder + "/certs/" + random_name + "-privkey.pem", 'w').write(privkey) + open(homefolder + "/certs/" + random_name + "-chain.pem", 'w').write(certt) + open(homefolder + "/certs/" + random_name + "-privkey.pem", 'w').write(privkeyy) resp = make_response('Success!

Go home

') resp.set_cookie('certname',random_name) return resp