summaryrefslogtreecommitdiffstats
path: root/base/server/python
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2016-04-15 02:30:00 +0200
committerEndi S. Dewata <edewata@redhat.com>2016-04-15 20:03:36 +0200
commitd3bbfe07b1cb2d65a7af6530ea01374b20a761e4 (patch)
tree1fd572a9a76b5bfc4610037b1c45ef5d8a63e4f4 /base/server/python
parent08f032de4090467ac4096f970609e19834b997ac (diff)
downloadpki-d3bbfe07b1cb2d65a7af6530ea01374b20a761e4.tar.gz
pki-d3bbfe07b1cb2d65a7af6530ea01374b20a761e4.tar.xz
pki-d3bbfe07b1cb2d65a7af6530ea01374b20a761e4.zip
Updated pki pkcs12-export CLI.
For consistency the pki pkcs12-export has been modified to overwrite the PKCS #12 output file by default. A new option has been added to append the exported certificates and keys into the output file if the file already exists. The same option has been added to the The pki-server instance-cert-export and subsystem-cert-export commands. https://fedorahosted.org/pki/ticket/1736
Diffstat (limited to 'base/server/python')
-rw-r--r--base/server/python/pki/server/cli/instance.py18
-rw-r--r--base/server/python/pki/server/cli/subsystem.py20
2 files changed, 29 insertions, 9 deletions
diff --git a/base/server/python/pki/server/cli/instance.py b/base/server/python/pki/server/cli/instance.py
index a779f3c16..4eeee5d60 100644
--- a/base/server/python/pki/server/cli/instance.py
+++ b/base/server/python/pki/server/cli/instance.py
@@ -76,7 +76,9 @@ class InstanceCertExportCLI(pki.cli.CLI):
print(' --pkcs12-file <path> Output file to store the exported certificate and key in PKCS #12 format.')
print(' --pkcs12-password <password> Password for the PKCS #12 file.')
print(' --pkcs12-password-file <path> Input file containing the password for the PKCS #12 file.')
+ print(' --append Append into an existing PKCS #12 file.')
print(' -v, --verbose Run in verbose mode.')
+ print(' --debug Run in debug mode.')
print(' --help Show help message.')
print()
@@ -86,7 +88,7 @@ class InstanceCertExportCLI(pki.cli.CLI):
opts, args = getopt.gnu_getopt(argv, 'i:v', [
'instance=',
'pkcs12-file=', 'pkcs12-password=', 'pkcs12-password-file=',
- 'verbose', 'help'])
+ 'append', 'verbose', 'debug', 'help'])
except getopt.GetoptError as e:
print('ERROR: ' + str(e))
@@ -99,6 +101,8 @@ class InstanceCertExportCLI(pki.cli.CLI):
pkcs12_file = None
pkcs12_password = None
pkcs12_password_file = None
+ append = False
+ debug = False
for o, a in opts:
if o in ('-i', '--instance'):
@@ -113,9 +117,15 @@ class InstanceCertExportCLI(pki.cli.CLI):
elif o == '--pkcs12-password-file':
pkcs12_password_file = a
+ elif o == '--append':
+ append = True
+
elif o in ('-v', '--verbose'):
self.set_verbose(True)
+ elif o == '--debug':
+ debug = True
+
elif o == '--help':
self.print_help()
sys.exit()
@@ -142,12 +152,12 @@ class InstanceCertExportCLI(pki.cli.CLI):
pkcs12_file=pkcs12_file,
pkcs12_password=pkcs12_password,
pkcs12_password_file=pkcs12_password_file,
- nicknames=nicknames)
+ nicknames=nicknames,
+ append=append,
+ debug=debug)
finally:
nssdb.close()
- self.print_message('Exported certificates')
-
class InstanceFindCLI(pki.cli.CLI):
diff --git a/base/server/python/pki/server/cli/subsystem.py b/base/server/python/pki/server/cli/subsystem.py
index 5ab232cc1..fe395aad6 100644
--- a/base/server/python/pki/server/cli/subsystem.py
+++ b/base/server/python/pki/server/cli/subsystem.py
@@ -464,7 +464,9 @@ class SubsystemCertExportCLI(pki.cli.CLI):
print(' --pkcs12-file <path> Output file to store the exported certificate and key in PKCS #12 format.')
print(' --pkcs12-password <password> Password for the PKCS #12 file.')
print(' --pkcs12-password-file <path> Input file containing the password for the PKCS #12 file.')
+ print(' --append Append into an existing PKCS #12 file.')
print(' -v, --verbose Run in verbose mode.')
+ print(' --debug Run in debug mode.')
print(' --help Show help message.')
print()
@@ -474,7 +476,7 @@ class SubsystemCertExportCLI(pki.cli.CLI):
opts, args = getopt.gnu_getopt(argv, 'i:v', [
'instance=', 'cert-file=', 'csr-file=',
'pkcs12-file=', 'pkcs12-password=', 'pkcs12-password-file=',
- 'verbose', 'help'])
+ 'append', 'verbose', 'debug', 'help'])
except getopt.GetoptError as e:
print('ERROR: ' + str(e))
@@ -494,6 +496,8 @@ class SubsystemCertExportCLI(pki.cli.CLI):
pkcs12_file = None
pkcs12_password = None
pkcs12_password_file = None
+ append = False
+ debug = False
for o, a in opts:
if o in ('-i', '--instance'):
@@ -514,9 +518,15 @@ class SubsystemCertExportCLI(pki.cli.CLI):
elif o == '--pkcs12-password-file':
pkcs12_password_file = a
+ elif o == '--append':
+ append = True
+
elif o in ('-v', '--verbose'):
self.set_verbose(True)
+ elif o == '--debug':
+ debug = True
+
elif o == '--help':
self.print_help()
sys.exit()
@@ -526,7 +536,7 @@ class SubsystemCertExportCLI(pki.cli.CLI):
self.print_help()
sys.exit(1)
- if not pkcs12_file:
+ if not (cert_file or csr_file or pkcs12_file):
print('ERROR: missing output file')
self.print_help()
sys.exit(1)
@@ -579,13 +589,13 @@ class SubsystemCertExportCLI(pki.cli.CLI):
pkcs12_file=pkcs12_file,
pkcs12_password=pkcs12_password,
pkcs12_password_file=pkcs12_password_file,
- nicknames=nicknames)
+ nicknames=nicknames,
+ append=append,
+ debug=debug)
finally:
nssdb.close()
- self.print_message('Export complete')
-
class SubsystemCertUpdateCLI(pki.cli.CLI):