diff options
author | Mike Milner <mike.milner@canonical.com> | 2012-01-14 10:49:09 +0000 |
---|---|---|
committer | Mike Milner <mike.milner@canonical.com> | 2012-01-14 10:49:09 +0000 |
commit | 094e915e91186401ebc7c97564917334faade150 (patch) | |
tree | 323bf15f4f49ca76dea569505ddf6293426a1204 /cloudinit/CloudConfig/cc_ca_certs.py | |
parent | a717e4f8b9210374edcc9053ca6ff980cb0cefff (diff) | |
download | vyos-cloud-init-094e915e91186401ebc7c97564917334faade150.tar.gz vyos-cloud-init-094e915e91186401ebc7c97564917334faade150.zip |
Factor out writing of certificates.
Diffstat (limited to 'cloudinit/CloudConfig/cc_ca_certs.py')
-rw-r--r-- | cloudinit/CloudConfig/cc_ca_certs.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/cloudinit/CloudConfig/cc_ca_certs.py b/cloudinit/CloudConfig/cc_ca_certs.py index 81ed7237..07074e2f 100644 --- a/cloudinit/CloudConfig/cc_ca_certs.py +++ b/cloudinit/CloudConfig/cc_ca_certs.py @@ -45,6 +45,17 @@ def update_ca_certs(): check_call(["dpkg-reconfigure", "ca-certificates"]) check_call(["update-ca-certificates"]) +def add_ca_certs(certs): + """ + Adds certificates to the system. To actually apply the new certificates + you must also call L{update_ca_certs}. + + @param certs: A list of certificate strings. + """ + if certs: + cert_file_contents = "\n".join(certs) + write_file(CERT_FILENAME, cert_file_contents, "root", "root", "644") + def handle(name, cfg, cloud, log, args): """ Call to handle ca-cert sections in cloud-config file. @@ -66,7 +77,5 @@ def handle(name, cfg, cloud, log, args): if ca_cert_cfg.has_key('trusted'): trusted_certs = util.get_cfg_option_list_or_str(ca_cert_cfg, 'trusted') if trusted_certs: - cert_file_contents = "\n".join(trusted_certs) - write_file(CERT_FILENAME, cert_file_contents, "root", "root", "644") - + add_ca_certs(trusted_certs) update_ca_certs() |