Update server.py
This commit is contained in:
parent
a8165546a3
commit
effd532e54
1 changed files with 6 additions and 4 deletions
10
server.py
10
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('<meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" href="/style.css">The certificate seems to already exist, loading the used file.<br><br><p><a href="/" class=go style="color: white;">Go home</a></p>')
|
||||
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('<meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="stylesheet" href="/style.css">Success!<br><br><p><a href="/" class=go style="color: white;">Go home</a></p>')
|
||||
resp.set_cookie('certname',random_name)
|
||||
return resp
|
||||
|
|
Loading…
Add table
Reference in a new issue