Update server.py
This commit is contained in:
parent
f761a2f536
commit
71d6f113ab
1 changed files with 5 additions and 6 deletions
11
server.py
11
server.py
|
@ -32,24 +32,23 @@ def loadcert_backend():
|
||||||
return "Invalid request. (cert is missing!)"
|
return "Invalid request. (cert is missing!)"
|
||||||
if 'privkey' not in request.files:
|
if 'privkey' not in request.files:
|
||||||
return "Invalid request. (privkey is missing!)"
|
return "Invalid request. (privkey is missing!)"
|
||||||
cert = request.files['cert']
|
cert = request.files['cert'].read()
|
||||||
privkey = request.files['privkey']
|
privkey = request.files['privkey'].read()
|
||||||
if cert.filename == '' or privkey.filename == '':
|
if cert.filename == '' or privkey.filename == '':
|
||||||
return "Please upload a certificate and private key."
|
return "Please upload a certificate and private key."
|
||||||
print(cert.read())
|
|
||||||
if allowed_file(cert.filename) and allowed_file(privkey.filename):
|
if allowed_file(cert.filename) and allowed_file(privkey.filename):
|
||||||
for i in os.listdir(homefolder + "/certs/"):
|
for i in os.listdir(homefolder + "/certs/"):
|
||||||
thisname = "-".join(i.split("-")[:-1])
|
thisname = "-".join(i.split("-")[:-1])
|
||||||
print(thisname)
|
print(thisname)
|
||||||
print(homefolder + "/certs/" + thisname + "-privkey.pem")
|
print(homefolder + "/certs/" + thisname + "-privkey.pem")
|
||||||
print([open(homefolder + "/certs/" + thisname + "-privkey.pem").read()])
|
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('<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 = 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)
|
resp.set_cookie('certname',thisname)
|
||||||
return resp
|
return resp
|
||||||
random_name = str(uuid.uuid4())
|
random_name = str(uuid.uuid4())
|
||||||
cert.save(homefolder + "/certs/" + random_name + "-chain.pem")
|
open(homefolder + "/certs/" + random_name + "-chain.pem", 'w').write(cert)
|
||||||
privkey.save(homefolder + "/certs/" + random_name + "-privkey.pem")
|
open(homefolder + "/certs/" + random_name + "-privkey.pem", 'w').write(privkey)
|
||||||
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 = 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)
|
resp.set_cookie('certname',random_name)
|
||||||
return resp
|
return resp
|
||||||
|
|
Loading…
Add table
Reference in a new issue