| Rajesh | 43076e5 | 2017-02-23 05:12:08 -0500 | [diff] [blame^] | 1 | # RIFT_IO_STANDARD_CMAKE_COPYRIGHT_HEADER(BEGIN) |
| 2 | # Creation Date: 2/5/16 |
| 3 | # RIFT_IO_STANDARD_CMAKE_COPYRIGHT_HEADER(END) |
| 4 | |
| 5 | import os |
| 6 | |
| 7 | class BootstrapSslMissingException(Exception): |
| 8 | pass |
| 9 | |
| 10 | # True if the environment variable is unset, otherwise False |
| 11 | USE_SSL = os.environ.get("RIFT_BOOT_WITHOUT_HTTPS", None) is None |
| 12 | |
| 13 | def get_bootstrap_cert_and_key(): |
| 14 | ''' |
| 15 | Lookup the bootstrap certificate and key and return their paths |
| 16 | ''' |
| 17 | |
| 18 | user_cert = os.path.join("/", "etc", "ssl", "current.cert") |
| 19 | user_key = os.path.join("/", "etc", "ssl", "current.key") |
| 20 | |
| 21 | if os.path.isfile(user_cert) and os.path.isfile(user_key): |
| 22 | return USE_SSL, user_cert, user_key |
| 23 | |
| 24 | rift_install = os.environ["RIFT_INSTALL"] |
| 25 | rift_cert = os.path.join(rift_install, "etc", "ssl", "current.cert") |
| 26 | rift_key = os.path.join(rift_install, "etc", "ssl", "current.key") |
| 27 | |
| 28 | if os.path.isfile(rift_cert) and os.path.isfile(rift_key): |
| 29 | return USE_SSL, rift_cert, rift_key |
| 30 | |
| 31 | raise BootstrapSslMissingException() |
| 32 | |