diff options
author | Abhijeet Kasurde <akasurde@redhat.com> | 2016-08-02 16:46:29 +0530 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2016-08-05 09:27:48 +0200 |
commit | 5178567bf5c65d23d3903b0956a47813bdc1fe23 (patch) | |
tree | d4e631bb859bbb1af0c86fcfe7ea6631badaa9aa | |
parent | 7702dae72b59a39b31b52640a9d1a4b5b6ca62ca (diff) | |
download | pki-5178567bf5c65d23d3903b0956a47813bdc1fe23.tar.gz pki-5178567bf5c65d23d3903b0956a47813bdc1fe23.tar.xz pki-5178567bf5c65d23d3903b0956a47813bdc1fe23.zip |
Added check for Subsystem data and request in 'pki-server subsystem-cert-export'
Partially fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1353245
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
-rw-r--r-- | base/server/python/pki/server/cli/subsystem.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/base/server/python/pki/server/cli/subsystem.py b/base/server/python/pki/server/cli/subsystem.py index a44243a67..4651d74db 100644 --- a/base/server/python/pki/server/cli/subsystem.py +++ b/base/server/python/pki/server/cli/subsystem.py @@ -1,5 +1,6 @@ # Authors: # Endi S. Dewata <edewata@redhat.com> +# Abhijeet Kasurde <akasurde@redhat.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,7 +15,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -# Copyright (C) 2015 Red Hat, Inc. +# Copyright (C) 2015-2016 Red Hat, Inc. # All rights reserved. # @@ -654,14 +655,22 @@ class SubsystemCertExportCLI(pki.cli.CLI): sys.exit(1) if cert_file: + cert_data = subsystem_cert.get('data', None) + if cert_data is None: + print("ERROR: Unable to find certificate data for %s" % cert_id) + sys.exit(1) - cert_data = pki.nssdb.convert_cert(subsystem_cert['data'], 'base64', 'pem') + cert_data = pki.nssdb.convert_cert(cert_data, 'base64', 'pem') with open(cert_file, 'w') as f: f.write(cert_data) if csr_file: + cert_request = subsystem_cert.get('request', None) + if cert_request is None: + print("ERROR: Unable to find certificate request for %s" % cert_id) + sys.exit(1) - csr_data = pki.nssdb.convert_csr(subsystem_cert['request'], 'base64', 'pem') + csr_data = pki.nssdb.convert_csr(cert_request, 'base64', 'pem') with open(csr_file, 'w') as f: f.write(csr_data) |