From: Rajesh Date: Thu, 23 Feb 2017 10:12:08 +0000 (-0500) Subject: Certs module initial checkin X-Git-Tag: v1.1.0~8 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F44%2F1144%2F1;p=osm%2Fdevops.git Certs module initial checkin --- 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() +