1
# Copyright 2014-2015 Canonical Limited.
3
# This file is part of charm-helpers.
5
# charm-helpers is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU Lesser General Public License version 3 as
7
# published by the Free Software Foundation.
9
# charm-helpers is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU Lesser General Public License for more details.
14
# You should have received a copy of the GNU Lesser General Public License
15
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
18
# Copyright 2012 Canonical Ltd.
20
# This file is sourced from lp:openstack-charm-helpers
23
# James Page <james.page@ubuntu.com>
24
# Adam Gandelman <adamg@ubuntu.com>
29
from charmhelpers.core.hookenv import (
33
related_units as relation_list,
39
def get_cert(cn=None):
40
# TODO: deal with multiple https endpoints via charm config
41
cert = config_get('ssl_cert')
42
key = config_get('ssl_key')
43
if not (cert and key):
44
log("Inspecting identity-service relations for SSL certificate.",
48
ssl_cert_attr = 'ssl_cert_{}'.format(cn)
49
ssl_key_attr = 'ssl_key_{}'.format(cn)
51
ssl_cert_attr = 'ssl_cert'
52
ssl_key_attr = 'ssl_key'
53
for r_id in relation_ids('identity-service'):
54
for unit in relation_list(r_id):
56
cert = relation_get(ssl_cert_attr,
59
key = relation_get(ssl_key_attr,
65
ca_cert = config_get('ssl_ca')
67
log("Inspecting identity-service relations for CA SSL certificate.",
69
for r_id in relation_ids('identity-service'):
70
for unit in relation_list(r_id):
72
ca_cert = relation_get('ca_cert',
77
def install_ca_cert(ca_cert):
79
with open('/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt',
82
subprocess.check_call(['update-ca-certificates', '--fresh'])