diff --git a/server.py b/server.py index 0ed207b..a653820 100644 --- a/server.py +++ b/server.py @@ -32,24 +32,23 @@ def loadcert_backend(): return "Invalid request. (cert is missing!)" if 'privkey' not in request.files: return "Invalid request. (privkey is missing!)" - cert = request.files['cert'] - privkey = request.files['privkey'] + cert = request.files['cert'].read() + privkey = request.files['privkey'].read() if cert.filename == '' or privkey.filename == '': return "Please upload a certificate and private key." - print(cert.read()) if allowed_file(cert.filename) and allowed_file(privkey.filename): for i in os.listdir(homefolder + "/certs/"): thisname = "-".join(i.split("-")[:-1]) print(thisname) print(homefolder + "/certs/" + thisname + "-privkey.pem") print([open(homefolder + "/certs/" + thisname + "-privkey.pem").read()]) - if (open(homefolder + "/certs/" + thisname + "-privkey.pem").read() == privkey.read()) and (open(homefolder + "/certs/" + thisname + "-chain.pem").read() == cert.read()): + if (open(homefolder + "/certs/" + thisname + "-privkey.pem").read() == privkey) and (open(homefolder + "/certs/" + thisname + "-chain.pem").read() == cert): 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()) - cert.save(homefolder + "/certs/" + random_name + "-chain.pem") - privkey.save(homefolder + "/certs/" + random_name + "-privkey.pem") + open(homefolder + "/certs/" + random_name + "-chain.pem", 'w').write(cert) + open(homefolder + "/certs/" + random_name + "-privkey.pem", 'w').write(privkey) resp = make_response('Success!

Go home

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