From 43076e5e64df247a65bb64965440edddde7606e6 Mon Sep 17 00:00:00 2001 From: Rajesh Date: Thu, 23 Feb 2017 05:12:08 -0500 Subject: [PATCH] Certs module initial checkin --- test/certs.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/certs.py diff --git a/test/certs.py b/test/certs.py new file mode 100644 index 00000000..595dd204 --- /dev/null +++ b/test/certs.py @@ -0,0 +1,32 @@ +# RIFT_IO_STANDARD_CMAKE_COPYRIGHT_HEADER(BEGIN) +# Creation Date: 2/5/16 +# RIFT_IO_STANDARD_CMAKE_COPYRIGHT_HEADER(END) + +import os + +class BootstrapSslMissingException(Exception): + pass + +# True if the environment variable is unset, otherwise False +USE_SSL = os.environ.get("RIFT_BOOT_WITHOUT_HTTPS", None) is None + +def get_bootstrap_cert_and_key(): + ''' + Lookup the bootstrap certificate and key and return their paths + ''' + + user_cert = os.path.join("/", "etc", "ssl", "current.cert") + user_key = os.path.join("/", "etc", "ssl", "current.key") + + if os.path.isfile(user_cert) and os.path.isfile(user_key): + return USE_SSL, user_cert, user_key + + rift_install = os.environ["RIFT_INSTALL"] + rift_cert = os.path.join(rift_install, "etc", "ssl", "current.cert") + rift_key = os.path.join(rift_install, "etc", "ssl", "current.key") + + if os.path.isfile(rift_cert) and os.path.isfile(rift_key): + return USE_SSL, rift_cert, rift_key + + raise BootstrapSslMissingException() + -- 2.25.1