1 # Copyright 2016 RIFT.IO Inc
2 # Copyright 2016 Telefónica Investigación y Desarrollo S.A.U.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 class BootstrapSslMissingException(Exception):
21 # True if the environment variable is unset, otherwise False
22 USE_SSL
= os
.environ
.get("RIFT_BOOT_WITHOUT_HTTPS", None) is None
24 def get_bootstrap_cert_and_key():
26 Lookup the bootstrap certificate and key and return their paths
29 user_cert
= os
.path
.join("/", "etc", "ssl", "current.cert")
30 user_key
= os
.path
.join("/", "etc", "ssl", "current.key")
32 if os
.path
.isfile(user_cert
) and os
.path
.isfile(user_key
):
33 return USE_SSL
, user_cert
, user_key
35 rift_install
= os
.environ
["RIFT_INSTALL"]
36 rift_cert
= os
.path
.join(rift_install
, "etc", "ssl", "current.cert")
37 rift_key
= os
.path
.join(rift_install
, "etc", "ssl", "current.key")
39 if os
.path
.isfile(rift_cert
) and os
.path
.isfile(rift_key
):
40 return USE_SSL
, rift_cert
, rift_key
42 raise BootstrapSslMissingException()