summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-05-09 19:41:23 -0300
committerJesusaves <cpntb1@ymail.com>2021-05-09 19:41:23 -0300
commit8711ed3c129e22f583608329528f9972db799b74 (patch)
treec16803cd25412ad942a47a6d4244bda44105d250
parentbf3e7340744907efad45eb7dc76c1769fd63966c (diff)
downloadrenpy-8711ed3c129e22f583608329528f9972db799b74.tar.gz
renpy-8711ed3c129e22f583608329528f9972db799b74.tar.bz2
renpy-8711ed3c129e22f583608329528f9972db799b74.tar.xz
renpy-8711ed3c129e22f583608329528f9972db799b74.zip
Always download the PEM certificate; No point keeping it in cache?
-rw-r--r--game/core.rpy49
1 files changed, 11 insertions, 38 deletions
diff --git a/game/core.rpy b/game/core.rpy
index bd0a44c..4ad83eb 100644
--- a/game/core.rpy
+++ b/game/core.rpy
@@ -150,45 +150,18 @@ init -3 python:
def build_vault():
while True:
try:
- # Certificate exists, so validate it
- if (os.path.exists(get_path("cert.pem"))):
- stdout("PEM Certificate: Validating...")
- cert=get_path("cert.pem")
- x509=ssl._ssl._test_decode_cert(cert)
- stdout("Expires on: %s" % str(x509["notAfter"]))
- date=x509["notAfter"].split(" ")
- year=0
- ## Attempt to retrieve year
- for arg in date:
- if len(arg) != 4:
- continue
- try:
- year=int(arg)
- break
- except:
- continue
- ## If year was found and is after today, keep going
- if (year+1) == datetime.datetime.utcnow().year:
- stdout("Expires on: %04d\nCertificate is good, continue." % year)
- else:
- stdout("Year not found, expiring, or invalid, fetch a new one")
- os.remove(cert)
-
######################################
- # Certificate does not exist, fetch it
- if (not os.path.exists(get_path("cert.pem"))):
- stdout("PEM Certificate not found; Fetching from %s" % VAULT_CERT)
- r = requests.get(VAULT_CERT)
- if (r.status_code != 200):
- raise Exception("\nFailed to fetch Vault SSL Certificate.\b\n Returned HTTP error %d.\n\nClick \"Ignore\" to retry.\n\n" % r.status_code)
- # Save it
- with open(get_path("cert.pem"), 'wb') as fd:
- for chunk in r.iter_content(chunk_size=128):
- fd.write(chunk)
- # Presumably all good, so do not continue and break the loop
- stdout("PEM Download OK")
- break
-
+ # Fetch a new PEM Certificate
+ stdout("Fetching SSL Certificate from %s" % VAULT_CERT)
+ r = requests.get(VAULT_CERT)
+ if (r.status_code != 200):
+ raise Exception("\nFailed to fetch Vault SSL Certificate.\b\n Returned HTTP error %d.\n\nClick \"Ignore\" to retry.\n\n" % r.status_code)
+ # Save it
+ with open(get_path("cert.pem"), 'wb') as fd:
+ for chunk in r.iter_content(chunk_size=128):
+ fd.write(chunk)
+ # Presumably all good, so do not continue and break the loop
+ stdout("PEM Download OK")
break
except:
traceback.print_exc()