Blame SOURCES/pki-core-10.5.9-batch-2.0.patch

5348b8
From 9c24a655511c911c8acc724a45f79b3ea4986b9f Mon Sep 17 00:00:00 2001
5348b8
From: Dinesh Prasanth M K <dmoluguw@redhat.com>
5348b8
Date: Thu, 1 Nov 2018 16:29:11 -0400
5348b8
Subject: [PATCH 01/13] Add --force flag to pki-destroy
5348b8
5348b8
Resolves: Bug 1372056
5348b8
Ticket: https://pagure.io/dogtagpki/issue/1172
5348b8
5348b8
List of changes with this commit:
5348b8
- Adds new flag `--force` to pkidestroy to force remove a subsystem
5348b8
- Use `os.path.join()` instead of appending '/' between path names
5348b8
- Remove the `pki_database_path` dir instead of removing contents of the dir
5348b8
    - This is moved to `security_database.py` instead of `configuration.py`
5348b8
- pkidestroy and pkispawn logs are owned by `root` instead of configured pkiuser
5348b8
5348b8
Signed-off-by: Dinesh Prasanth M K<dmoluguw@redhat.com>
5348b8
(cherry picked from commit 926c26e10db1b3fde8f24802d7a77419d0f2f28d)
5348b8
---
5348b8
 .../python/pki/server/deployment/pkihelper.py      |  6 +-
5348b8
 .../server/deployment/scriptlets/configuration.py  |  7 +-
5348b8
 .../server/deployment/scriptlets/finalization.py   |  5 +-
5348b8
 .../server/deployment/scriptlets/initialization.py | 92 ++++++++++++----------
5348b8
 .../deployment/scriptlets/security_databases.py    |  8 +-
5348b8
 .../deployment/scriptlets/webapp_deployment.py     |  2 +-
5348b8
 base/server/sbin/pkidestroy                        | 44 ++++++++---
5348b8
 7 files changed, 96 insertions(+), 68 deletions(-)
5348b8
5348b8
diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py
5348b8
index 79f1e57..e1b9a02 100644
5348b8
--- a/base/server/python/pki/server/deployment/pkihelper.py
5348b8
+++ b/base/server/python/pki/server/deployment/pkihelper.py
5348b8
@@ -947,8 +947,10 @@ class Instance:
5348b8
         rv = []
5348b8
         try:
5348b8
             for subsystem in config.PKI_TOMCAT_SUBSYSTEMS:
5348b8
-                path = self.mdict['pki_instance_path'] + \
5348b8
-                    "/" + subsystem.lower()
5348b8
+                path = os.path.join(
5348b8
+                    self.mdict['pki_instance_path'],
5348b8
+                    subsystem.lower()
5348b8
+                )
5348b8
                 if os.path.exists(path) and os.path.isdir(path):
5348b8
                     rv.append(subsystem)
5348b8
         except OSError as exc:
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/configuration.py b/base/server/python/pki/server/deployment/scriptlets/configuration.py
5348b8
index 1b62445..7bc0023 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/configuration.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/configuration.py
5348b8
@@ -1274,9 +1274,4 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
             raise RuntimeError("server failed to restart")
5348b8
 
5348b8
     def destroy(self, deployer):
5348b8
-
5348b8
-        config.pki_log.info(log.CONFIGURATION_DESTROY_1, __name__,
5348b8
-                            extra=config.PKI_INDENTATION_LEVEL_1)
5348b8
-        if len(deployer.instance.tomcat_instance_subsystems()) == 1:
5348b8
-            if deployer.directory.exists(deployer.mdict['pki_client_dir']):
5348b8
-                deployer.directory.delete(deployer.mdict['pki_client_dir'])
5348b8
+        pass
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/finalization.py b/base/server/python/pki/server/deployment/scriptlets/finalization.py
5348b8
index e62051f..3c7e118 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/finalization.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/finalization.py
5348b8
@@ -68,19 +68,18 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
                             deployer.mdict['pki_subsystem'],
5348b8
                             deployer.mdict['pki_instance_name'],
5348b8
                             extra=config.PKI_INDENTATION_LEVEL_0)
5348b8
-        deployer.file.modify(deployer.mdict['pki_spawn_log'], silent=True)
5348b8
 
5348b8
     def destroy(self, deployer):
5348b8
 
5348b8
         config.pki_log.info(log.FINALIZATION_DESTROY_1, __name__,
5348b8
                             extra=config.PKI_INDENTATION_LEVEL_1)
5348b8
-        deployer.file.modify(deployer.mdict['pki_destroy_log'], silent=True)
5348b8
         # If this is the last remaining PKI instance, ALWAYS remove the
5348b8
         # link to start configured PKI instances upon system reboot
5348b8
         if deployer.mdict['pki_subsystem'] in config.PKI_SUBSYSTEMS and\
5348b8
            deployer.instance.pki_instance_subsystems() == 0:
5348b8
             deployer.systemd.disable()
5348b8
-        # Start this Tomcat PKI Process
5348b8
+
5348b8
+        # Start this Tomcat PKI Process back if there are any subsystems still existing
5348b8
         if len(deployer.instance.tomcat_instance_subsystems()) >= 1:
5348b8
             deployer.systemd.start()
5348b8
         config.pki_log.info(log.PKIDESTROY_END_MESSAGE_2,
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/initialization.py b/base/server/python/pki/server/deployment/scriptlets/initialization.py
5348b8
index 9528ec5..efd1536 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/initialization.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/initialization.py
5348b8
@@ -86,45 +86,53 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
         deployer.configuration_file.verify_ds_secure_connection_data()
5348b8
 
5348b8
     def destroy(self, deployer):
5348b8
-
5348b8
-        # begin official logging
5348b8
-        config.pki_log.info(log.PKIDESTROY_BEGIN_MESSAGE_2,
5348b8
-                            deployer.mdict['pki_subsystem'],
5348b8
-                            deployer.mdict['pki_instance_name'],
5348b8
-                            extra=config.PKI_INDENTATION_LEVEL_0)
5348b8
-        config.pki_log.info(log.INITIALIZATION_DESTROY_1, __name__,
5348b8
-                            extra=config.PKI_INDENTATION_LEVEL_1)
5348b8
-        # verify that this type of "subsystem" currently EXISTS
5348b8
-        # for this "instance"
5348b8
-        deployer.instance.verify_subsystem_exists()
5348b8
-        # verify that the command-line parameters match the values
5348b8
-        # that are present in the corresponding configuration file
5348b8
-        deployer.configuration_file.verify_command_matches_configuration_file()
5348b8
-        # establish 'uid' and 'gid'
5348b8
-        deployer.identity.set_uid(deployer.mdict['pki_user'])
5348b8
-        deployer.identity.set_gid(deployer.mdict['pki_group'])
5348b8
-        # get ports to remove selinux context
5348b8
-        deployer.configuration_file.populate_non_default_ports()
5348b8
-
5348b8
-        # remove kra connector from CA if this is a KRA
5348b8
-        deployer.kra_connector.deregister()
5348b8
-
5348b8
-        # remove tps connector from TKS if this is a TPS
5348b8
-        deployer.tps_connector.deregister()
5348b8
-
5348b8
-        # de-register instance from its Security Domain
5348b8
-        #
5348b8
-        #     NOTE:  Since the security domain of an instance must be up
5348b8
-        #            and running in order to be de-registered, this step
5348b8
-        #            must be done PRIOR to instance shutdown because this
5348b8
-        #            instance's security domain may be a part of a
5348b8
-        #            tightly-coupled shared instance.
5348b8
-        #
5348b8
-
5348b8
-        # Previously we obtained the token through a command line interface
5348b8
-        # no longer supported. Thus we assume no token and the deregister op will
5348b8
-        # take place without the token using an alternate method.
5348b8
-
5348b8
-        deployer.security_domain.deregister(None)
5348b8
-        # ALWAYS Stop this Tomcat PKI Process
5348b8
-        deployer.systemd.stop()
5348b8
+        try:
5348b8
+            # begin official logging
5348b8
+            config.pki_log.info(log.PKIDESTROY_BEGIN_MESSAGE_2,
5348b8
+                                deployer.mdict['pki_subsystem'],
5348b8
+                                deployer.mdict['pki_instance_name'],
5348b8
+                                extra=config.PKI_INDENTATION_LEVEL_0)
5348b8
+            config.pki_log.info(log.INITIALIZATION_DESTROY_1, __name__,
5348b8
+                                extra=config.PKI_INDENTATION_LEVEL_1)
5348b8
+            # verify that this type of "subsystem" currently EXISTS
5348b8
+            # for this "instance"
5348b8
+            deployer.instance.verify_subsystem_exists()
5348b8
+            # verify that the command-line parameters match the values
5348b8
+            # that are present in the corresponding configuration file
5348b8
+            deployer.configuration_file.verify_command_matches_configuration_file()
5348b8
+            # establish 'uid' and 'gid'
5348b8
+            deployer.identity.set_uid(deployer.mdict['pki_user'])
5348b8
+            deployer.identity.set_gid(deployer.mdict['pki_group'])
5348b8
+            # get ports to remove selinux context
5348b8
+            deployer.configuration_file.populate_non_default_ports()
5348b8
+
5348b8
+            # remove kra connector from CA if this is a KRA
5348b8
+            deployer.kra_connector.deregister()
5348b8
+
5348b8
+            # remove tps connector from TKS if this is a TPS
5348b8
+            deployer.tps_connector.deregister()
5348b8
+
5348b8
+            # de-register instance from its Security Domain
5348b8
+            #
5348b8
+            #     NOTE:  Since the security domain of an instance must be up
5348b8
+            #            and running in order to be de-registered, this step
5348b8
+            #            must be done PRIOR to instance shutdown because this
5348b8
+            #            instance's security domain may be a part of a
5348b8
+            #            tightly-coupled shared instance.
5348b8
+            #
5348b8
+
5348b8
+            # Previously we obtained the token through a command line interface
5348b8
+            # no longer supported. Thus we assume no token and the deregister op will
5348b8
+            # take place without the token using an alternate method.
5348b8
+
5348b8
+            deployer.security_domain.deregister(None)
5348b8
+
5348b8
+        except Exception as e:  # pylint: disable=broad-except
5348b8
+            config.pki_log.error(str(e))
5348b8
+            # If it is a normal destroy, pass any exception
5348b8
+            if not deployer.mdict['pki_force_destroy']:
5348b8
+                raise
5348b8
+
5348b8
+        finally:
5348b8
+            # ALWAYS Stop this Tomcat PKI Process
5348b8
+            deployer.systemd.stop()
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/security_databases.py b/base/server/python/pki/server/deployment/scriptlets/security_databases.py
5348b8
index b8550ad..02f4713 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/security_databases.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/security_databases.py
5348b8
@@ -259,7 +259,9 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
         config.pki_log.info(log.SECURITY_DATABASES_DESTROY_1, __name__,
5348b8
                             extra=config.PKI_INDENTATION_LEVEL_1)
5348b8
         if len(deployer.instance.tomcat_instance_subsystems()) == 0:
5348b8
-            deployer.file.delete(deployer.mdict['pki_cert_database'])
5348b8
-            deployer.file.delete(deployer.mdict['pki_key_database'])
5348b8
-            deployer.file.delete(deployer.mdict['pki_secmod_database'])
5348b8
+
5348b8
+            if deployer.directory.exists(deployer.mdict['pki_client_dir']):
5348b8
+                deployer.directory.delete(deployer.mdict['pki_client_dir'])
5348b8
+
5348b8
+            deployer.directory.delete(deployer.mdict['pki_database_path'])
5348b8
             deployer.file.delete(deployer.mdict['pki_shared_password_conf'])
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py b/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
5348b8
index bfa3c32..8957d9d 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
5348b8
@@ -70,7 +70,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
         config.pki_log.info(log.WEBAPP_DEPLOYMENT_DESTROY_1, __name__,
5348b8
                             extra=config.PKI_INDENTATION_LEVEL_1)
5348b8
 
5348b8
-        # Delete <instance>/conf/Catalina/localhost/<subsystem>.xml
5348b8
+        # Delete <instance>/Catalina/localhost/<subsystem>.xml
5348b8
         deployer.file.delete(
5348b8
             os.path.join(
5348b8
                 deployer.mdict['pki_instance_configuration_path'],
5348b8
diff --git a/base/server/sbin/pkidestroy b/base/server/sbin/pkidestroy
5348b8
index 58f0541..4692e36 100755
5348b8
--- a/base/server/sbin/pkidestroy
5348b8
+++ b/base/server/sbin/pkidestroy
5348b8
@@ -95,6 +95,13 @@ def main(argv):
5348b8
         nargs=1, metavar='<security domain password file>',
5348b8
         help='security domain password file path')
5348b8
 
5348b8
+    parser.optional.add_argument(
5348b8
+        '--force',
5348b8
+        dest='pki_force_destroy',
5348b8
+        action='store_true',
5348b8
+        help='force removal of subsystem'
5348b8
+    )
5348b8
+
5348b8
     args = parser.process_command_line_arguments()
5348b8
 
5348b8
     interactive = False
5348b8
@@ -155,20 +162,26 @@ def main(argv):
5348b8
                 pwd_file:
5348b8
             config.pki_secdomain_pass = pwd_file.readline().strip('\n')
5348b8
 
5348b8
+    #   '--force'
5348b8
+    force_destroy = args.pki_force_destroy
5348b8
+
5348b8
     # verify that previously deployed instance exists
5348b8
-    deployed_pki_instance_path = \
5348b8
-        config.pki_root_prefix + config.PKI_DEPLOYMENT_BASE_ROOT + "/" + \
5348b8
-        config.pki_deployed_instance_name
5348b8
-    if not os.path.exists(deployed_pki_instance_path):
5348b8
+    deployed_pki_instance_path = os.path.join(
5348b8
+        config.PKI_DEPLOYMENT_BASE_ROOT, config.pki_deployed_instance_name
5348b8
+    )
5348b8
+
5348b8
+    if not os.path.exists(deployed_pki_instance_path) and not force_destroy:
5348b8
         print("ERROR:  " + log.PKI_INSTANCE_DOES_NOT_EXIST_1 %
5348b8
               deployed_pki_instance_path)
5348b8
         print()
5348b8
         parser.arg_parser.exit(-1)
5348b8
 
5348b8
     # verify that previously deployed subsystem for this instance exists
5348b8
-    deployed_pki_subsystem_path = \
5348b8
-        deployed_pki_instance_path + "/" + deployer.subsystem_name.lower()
5348b8
-    if not os.path.exists(deployed_pki_subsystem_path):
5348b8
+    deployed_pki_subsystem_path = os.path.join(
5348b8
+        deployed_pki_instance_path, deployer.subsystem_name.lower()
5348b8
+    )
5348b8
+
5348b8
+    if not os.path.exists(deployed_pki_subsystem_path) and not force_destroy:
5348b8
         print("ERROR:  " + log.PKI_SUBSYSTEM_DOES_NOT_EXIST_2 %
5348b8
               (deployer.subsystem_name, deployed_pki_instance_path))
5348b8
         print()
5348b8
@@ -178,11 +191,16 @@ def main(argv):
5348b8
         config.PKI_DEPLOYMENT_DEFAULT_CONFIGURATION_FILE
5348b8
 
5348b8
     # establish complete path to previously deployed configuration file
5348b8
-    config.user_deployment_cfg =\
5348b8
-        deployed_pki_subsystem_path + "/" +\
5348b8
-        "registry" + "/" +\
5348b8
-        deployer.subsystem_name.lower() + "/" +\
5348b8
+    config.user_deployment_cfg = os.path.join(
5348b8
+        deployed_pki_subsystem_path,
5348b8
+        "registry",
5348b8
+        deployer.subsystem_name.lower(),
5348b8
         config.USER_DEPLOYMENT_CONFIGURATION
5348b8
+    )
5348b8
+
5348b8
+    if force_destroy and not os.path.exists(config.user_deployment_cfg):
5348b8
+        # During force destroy, try to load the file. If file doesn't exist, we ignore it
5348b8
+        config.user_deployment_cfg = None
5348b8
 
5348b8
     parser.validate()
5348b8
     parser.init_config()
5348b8
@@ -213,6 +231,10 @@ def main(argv):
5348b8
     parser.compose_pki_master_dictionary()
5348b8
     parser.mdict['pki_destroy_log'] = \
5348b8
         config.pki_log_dir + "/" + config.pki_log_name
5348b8
+
5348b8
+    # Add force_destroy to master dictionary
5348b8
+    parser.mdict['pki_force_destroy'] = force_destroy
5348b8
+
5348b8
     config.pki_log.debug(log.PKI_DICTIONARY_MASTER,
5348b8
                          extra=config.PKI_INDENTATION_LEVEL_0)
5348b8
     config.pki_log.debug(pkilogging.log_format(parser.mdict),
5348b8
-- 
5348b8
1.8.3.1
5348b8
5348b8
5348b8
From 7f0af3958605c9826c5bb71fcb43cfccb3056d90 Mon Sep 17 00:00:00 2001
5348b8
From: Dinesh Prasanth M K <dmoluguw@redhat.com>
5348b8
Date: Thu, 1 Nov 2018 16:43:36 -0400
5348b8
Subject: [PATCH 02/13] Add --remove-logs flag to pki-destroy
5348b8
5348b8
Partially resolves: Bug 1372056
5348b8
5348b8
List of changes by this commit:
5348b8
5348b8
- Logs are preserved by default (comment #1 in BZ)
5348b8
- Add `--remove-flags` flag to pkidestroy to remove logs
5348b8
5348b8
Signed-off-by: Dinesh Prasanth M K <dmoluguw@redhat.com>
5348b8
(cherry picked from commit 9e2cdb0b2f5df552ef50ba7883b4c686adec41b3)
5348b8
---
5348b8
 .../server/deployment/scriptlets/instance_layout.py   |  7 +++++--
5348b8
 .../server/deployment/scriptlets/subsystem_layout.py  | 19 +++++++++++--------
5348b8
 base/server/sbin/pkidestroy                           | 13 +++++++++++++
5348b8
 3 files changed, 29 insertions(+), 10 deletions(-)
5348b8
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/instance_layout.py b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
5348b8
index 2095212..568c0a0 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
5348b8
@@ -199,8 +199,11 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
 
5348b8
         # remove Tomcat instance base
5348b8
         deployer.directory.delete(deployer.mdict['pki_instance_path'])
5348b8
-        # remove Tomcat instance logs
5348b8
-        deployer.directory.delete(deployer.mdict['pki_instance_log_path'])
5348b8
+
5348b8
+        # remove Tomcat instance logs only if --remove-logs is specified
5348b8
+        if deployer.mdict['pki_remove_logs']:
5348b8
+            deployer.directory.delete(deployer.mdict['pki_instance_log_path'])
5348b8
+
5348b8
         # remove shared NSS security database path for this instance
5348b8
         deployer.directory.delete(deployer.mdict['pki_database_path'])
5348b8
         # remove Tomcat instance configuration
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py b/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
5348b8
index a0e4658..fb9f754 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
5348b8
@@ -124,15 +124,18 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
             deployer.directory.delete(
5348b8
                 deployer.mdict['pki_subsystem_profiles_path'])
5348b8
         deployer.directory.delete(deployer.mdict['pki_subsystem_path'])
5348b8
-        # remove instance-based subsystem logs
5348b8
-        if deployer.mdict['pki_subsystem'] in \
5348b8
-                config.PKI_SIGNED_AUDIT_SUBSYSTEMS:
5348b8
+
5348b8
+        # remove instance-based subsystem logs only if --remove-logs flag is specified
5348b8
+        if deployer.mdict['pki_remove_logs']:
5348b8
+            if deployer.mdict['pki_subsystem'] in \
5348b8
+                    config.PKI_SIGNED_AUDIT_SUBSYSTEMS:
5348b8
+                deployer.directory.delete(
5348b8
+                    deployer.mdict['pki_subsystem_signed_audit_log_path'])
5348b8
             deployer.directory.delete(
5348b8
-                deployer.mdict['pki_subsystem_signed_audit_log_path'])
5348b8
-        deployer.directory.delete(
5348b8
-            deployer.mdict['pki_subsystem_archive_log_path'])
5348b8
-        deployer.directory.delete(
5348b8
-            deployer.mdict['pki_subsystem_log_path'])
5348b8
+                deployer.mdict['pki_subsystem_archive_log_path'])
5348b8
+            deployer.directory.delete(
5348b8
+                deployer.mdict['pki_subsystem_log_path'])
5348b8
+
5348b8
         # remove instance-based subsystem configuration
5348b8
         deployer.directory.delete(
5348b8
             deployer.mdict['pki_subsystem_configuration_path'])
5348b8
diff --git a/base/server/sbin/pkidestroy b/base/server/sbin/pkidestroy
5348b8
index 4692e36..4095d13 100755
5348b8
--- a/base/server/sbin/pkidestroy
5348b8
+++ b/base/server/sbin/pkidestroy
5348b8
@@ -102,6 +102,13 @@ def main(argv):
5348b8
         help='force removal of subsystem'
5348b8
     )
5348b8
 
5348b8
+    parser.optional.add_argument(
5348b8
+        '--remove-logs',
5348b8
+        dest='pki_remove_logs',
5348b8
+        action='store_true',
5348b8
+        help='remove subsystem logs'
5348b8
+    )
5348b8
+
5348b8
     args = parser.process_command_line_arguments()
5348b8
 
5348b8
     interactive = False
5348b8
@@ -165,6 +172,9 @@ def main(argv):
5348b8
     #   '--force'
5348b8
     force_destroy = args.pki_force_destroy
5348b8
 
5348b8
+    #   '--remove-logs'
5348b8
+    remove_logs = args.pki_remove_logs
5348b8
+
5348b8
     # verify that previously deployed instance exists
5348b8
     deployed_pki_instance_path = os.path.join(
5348b8
         config.PKI_DEPLOYMENT_BASE_ROOT, config.pki_deployed_instance_name
5348b8
@@ -235,6 +245,9 @@ def main(argv):
5348b8
     # Add force_destroy to master dictionary
5348b8
     parser.mdict['pki_force_destroy'] = force_destroy
5348b8
 
5348b8
+    # Add remove logs to master dictionary
5348b8
+    parser.mdict['pki_remove_logs'] = remove_logs
5348b8
+
5348b8
     config.pki_log.debug(log.PKI_DICTIONARY_MASTER,
5348b8
                          extra=config.PKI_INDENTATION_LEVEL_0)
5348b8
     config.pki_log.debug(pkilogging.log_format(parser.mdict),
5348b8
-- 
5348b8
1.8.3.1
5348b8
5348b8
5348b8
From 24405fac463e59250ccf42507bba7fb811e3a2fb Mon Sep 17 00:00:00 2001
5348b8
From: Dinesh Prasanth M K <dmoluguw@redhat.com>
5348b8
Date: Thu, 1 Nov 2018 17:02:03 -0400
5348b8
Subject: [PATCH 03/13] Reuse same instance log dirs (if exists)
5348b8
5348b8
Resolves: Bug 1644769
5348b8
Ticket: https://pagure.io/dogtagpki/issue/3077
5348b8
5348b8
- `pkidestroy` behaviour was chagned to preserve the logs by default.
5348b8
  When `pkispawn` is run, it throws a name space collision error.
5348b8
- This patch reuses the log dir and appends logs to the same log dir
5348b8
  structure (if exists) and logs it accordingly.
5348b8
5348b8
`Signed-off-by: Dinesh Prasanth M K <dmoluguw@redhat.com>`
5348b8
5348b8
(cherry picked from commit c6c6757b4c566d10d25fe220fa9f59539c7a55ee)
5348b8
---
5348b8
 base/server/python/pki/server/deployment/pkihelper.py   | 12 +++++-------
5348b8
 base/server/python/pki/server/deployment/pkimessages.py |  2 ++
5348b8
 2 files changed, 7 insertions(+), 7 deletions(-)
5348b8
5348b8
diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py
5348b8
index e1b9a02..3b55f78 100644
5348b8
--- a/base/server/python/pki/server/deployment/pkihelper.py
5348b8
+++ b/base/server/python/pki/server/deployment/pkihelper.py
5348b8
@@ -345,18 +345,16 @@ class Namespace:
5348b8
                     log.PKIHELPER_NAMESPACE_COLLISION_2 % (
5348b8
                         self.mdict['pki_instance_name'],
5348b8
                         self.mdict['pki_cgroup_cpu_systemd_service_path']))
5348b8
+
5348b8
         if os.path.exists(self.mdict['pki_instance_log_path']) and\
5348b8
            os.path.exists(self.mdict['pki_subsystem_log_path']):
5348b8
-            # Top-Level PKI log path collision
5348b8
-            config.pki_log.error(
5348b8
-                log.PKIHELPER_NAMESPACE_COLLISION_2,
5348b8
+            # Check if logs already exist. If so, append to it. Log it as info
5348b8
+            config.pki_log.info(
5348b8
+                log.PKIHELPER_LOG_REUSE,
5348b8
                 self.mdict['pki_instance_name'],
5348b8
                 self.mdict['pki_instance_log_path'],
5348b8
                 extra=config.PKI_INDENTATION_LEVEL_2)
5348b8
-            raise Exception(
5348b8
-                log.PKIHELPER_NAMESPACE_COLLISION_2 % (
5348b8
-                    self.mdict['pki_instance_name'],
5348b8
-                    self.mdict['pki_instance_log_path']))
5348b8
+
5348b8
         if os.path.exists(self.mdict['pki_instance_configuration_path']) and\
5348b8
            os.path.exists(self.mdict['pki_subsystem_configuration_path']):
5348b8
             # Top-Level PKI configuration path collision
5348b8
diff --git a/base/server/python/pki/server/deployment/pkimessages.py b/base/server/python/pki/server/deployment/pkimessages.py
5348b8
index 7bb79ca..6539295 100644
5348b8
--- a/base/server/python/pki/server/deployment/pkimessages.py
5348b8
+++ b/base/server/python/pki/server/deployment/pkimessages.py
5348b8
@@ -277,6 +277,8 @@ PKIHELPER_NAMESPACE_COLLISION_2 = \
5348b8
     "PKI instance '%s' would produce a namespace collision with '%s'!"
5348b8
 PKIHELPER_NAMESPACE_RESERVED_NAME_2 = \
5348b8
     "PKI instance '%s' is already a reserved name under '%s'!"
5348b8
+PKIHELPER_LOG_REUSE = \
5348b8
+    "previous logs of PKI instance '%s' already exist. Appending logs to '%s'"
5348b8
 PKIHELPER_NCIPHER_RESTART_1 = "executing '%s'"
5348b8
 PKIHELPER_NOISE_FILE_2 = \
5348b8
     "generating noise file called '%s' and filling it with '%d' random bytes"
5348b8
-- 
5348b8
1.8.3.1
5348b8
5348b8
5348b8
From 2a0d9c8c8ee7333198a8f5cb09c988eeeb3d528f Mon Sep 17 00:00:00 2001
5348b8
From: "Endi S. Dewata" <edewata@redhat.com>
5348b8
Date: Wed, 22 Aug 2018 00:02:03 +0200
5348b8
Subject: [PATCH 04/13] Updated pki.nssdb to support multiple CSR delimiters
5348b8
 types
5348b8
5348b8
The pki.nssdb module has been modified to support both standard
5348b8
and legacy CSR delimiters as defined in RFC 7468.
5348b8
5348b8
https://pagure.io/dogtagpki/issue/3053
5348b8
5348b8
Change-Id: I609d640a66357f5293ff3a565027c1a395a47db7
5348b8
(cherry picked from commit 8bf25507886c446594fa1bd82e3040ab79b271b3)
5348b8
---
5348b8
 base/common/python/pki/nssdb.py | 46 ++++++++++++++++++++++++++++++++++-------
5348b8
 1 file changed, 39 insertions(+), 7 deletions(-)
5348b8
5348b8
diff --git a/base/common/python/pki/nssdb.py b/base/common/python/pki/nssdb.py
5348b8
index f350255..d4ae804 100644
5348b8
--- a/base/common/python/pki/nssdb.py
5348b8
+++ b/base/common/python/pki/nssdb.py
5348b8
@@ -34,8 +34,11 @@ from cryptography.hazmat.backends import default_backend
5348b8
 
5348b8
 import pki
5348b8
 
5348b8
-CSR_HEADER = '-----BEGIN NEW CERTIFICATE REQUEST-----'
5348b8
-CSR_FOOTER = '-----END NEW CERTIFICATE REQUEST-----'
5348b8
+CSR_HEADER = '-----BEGIN CERTIFICATE REQUEST-----'
5348b8
+CSR_FOOTER = '-----END CERTIFICATE REQUEST-----'
5348b8
+
5348b8
+LEGACY_CSR_HEADER = '-----BEGIN NEW CERTIFICATE REQUEST-----'
5348b8
+LEGACY_CSR_FOOTER = '-----END NEW CERTIFICATE REQUEST-----'
5348b8
 
5348b8
 CERT_HEADER = '-----BEGIN CERTIFICATE-----'
5348b8
 CERT_FOOTER = '-----END CERTIFICATE-----'
5348b8
@@ -51,10 +54,18 @@ logger = logging.LoggerAdapter(
5348b8
     extra={'indent': ''})
5348b8
 
5348b8
 
5348b8
-def convert_data(data, input_format, output_format, header=None, footer=None):
5348b8
+def convert_data(data, input_format, output_format,
5348b8
+                 header=None, footer=None,
5348b8
+                 headers=None, footers=None):
5348b8
+    '''
5348b8
+    This method converts a PEM file to base-64 and vice versa.
5348b8
+    It supports CSR, certificate, and PKCS #7 certificate chain.
5348b8
+    '''
5348b8
+
5348b8
     if input_format == output_format:
5348b8
         return data
5348b8
 
5348b8
+    # converting from base-64 to PEM
5348b8
     if input_format == 'base64' and output_format == 'pem':
5348b8
 
5348b8
         # join base-64 data into a single line
5348b8
@@ -66,16 +77,30 @@ def convert_data(data, input_format, output_format, header=None, footer=None):
5348b8
         # add header and footer
5348b8
         return '%s\n%s\n%s\n' % (header, '\n'.join(lines), footer)
5348b8
 
5348b8
+    # converting from PEM to base-64
5348b8
     if input_format == 'pem' and output_format == 'base64':
5348b8
 
5348b8
+        # initialize list of headers if not provided
5348b8
+        if not headers:
5348b8
+            headers = [header]
5348b8
+
5348b8
+        # initialize list of footers if not provided
5348b8
+        if not footers:
5348b8
+            footers = [footer]
5348b8
+
5348b8
         # join multiple lines into a single line
5348b8
         lines = []
5348b8
         for line in data.splitlines():
5348b8
             line = line.rstrip('\r\n')
5348b8
-            if line == header:
5348b8
+
5348b8
+            # if the line is a header, skip
5348b8
+            if line in headers:
5348b8
                 continue
5348b8
-            if line == footer:
5348b8
+
5348b8
+            # if the line is a footer, skip
5348b8
+            if line in footers:
5348b8
                 continue
5348b8
+
5348b8
             lines.append(line)
5348b8
 
5348b8
         return ''.join(lines)
5348b8
@@ -86,7 +111,9 @@ def convert_data(data, input_format, output_format, header=None, footer=None):
5348b8
 
5348b8
 def convert_csr(csr_data, input_format, output_format):
5348b8
     return convert_data(csr_data, input_format, output_format,
5348b8
-                        CSR_HEADER, CSR_FOOTER)
5348b8
+                        CSR_HEADER, CSR_FOOTER,
5348b8
+                        headers=[CSR_HEADER, LEGACY_CSR_HEADER],
5348b8
+                        footers=[CSR_FOOTER, LEGACY_CSR_FOOTER])
5348b8
 
5348b8
 
5348b8
 def convert_cert(cert_data, input_format, output_format):
5348b8
@@ -100,10 +127,15 @@ def convert_pkcs7(pkcs7_data, input_format, output_format):
5348b8
 
5348b8
 
5348b8
 def get_file_type(filename):
5348b8
+    '''
5348b8
+    This method detects the content of a PEM file. It supports
5348b8
+    CSR, certificate, PKCS #7 certificate chain.
5348b8
+    '''
5348b8
+
5348b8
     with open(filename, 'r') as f:
5348b8
         data = f.read()
5348b8
 
5348b8
-    if data.startswith(CSR_HEADER):
5348b8
+    if data.startswith(CSR_HEADER) or data.startswith(LEGACY_CSR_HEADER):
5348b8
         return 'csr'
5348b8
 
5348b8
     if data.startswith(CERT_HEADER):
5348b8
-- 
5348b8
1.8.3.1
5348b8
5348b8
5348b8
From b9867142f4971a98b6c79ba16788db8829dfd79d Mon Sep 17 00:00:00 2001
5348b8
From: "Endi S. Dewata" <edewata@redhat.com>
5348b8
Date: Mon, 20 Aug 2018 23:14:25 +0200
5348b8
Subject: [PATCH 05/13] Removed default CSR paths
5348b8
5348b8
The default.cfg has been modified to remove default CSR paths.
5348b8
5348b8
The verify_predefined_configuration_file_data() has been modified
5348b8
to no longer require CSR path parameters in the first step of
5348b8
external CA scenario.
5348b8
5348b8
https://pagure.io/dogtagpki/issue/3053
5348b8
5348b8
Change-Id: Idef6849b8bd7ee00d13151e0de10357a1f1d9ef2
5348b8
(cherry picked from commit f3dc6c79370d8b57362272c40bd9f67aaf791710)
5348b8
---
5348b8
 base/server/etc/default.cfg                        | 24 ++++++++--------
5348b8
 .../python/pki/server/deployment/pkihelper.py      | 32 +---------------------
5348b8
 2 files changed, 13 insertions(+), 43 deletions(-)
5348b8
5348b8
diff --git a/base/server/etc/default.cfg b/base/server/etc/default.cfg
5348b8
index b92cca7..2c0430a 100644
5348b8
--- a/base/server/etc/default.cfg
5348b8
+++ b/base/server/etc/default.cfg
5348b8
@@ -330,7 +330,7 @@ pki_ca_signing_subject_dn=cn=CA Signing Certificate,ou=%(pki_instance_name)s,o=%
5348b8
 pki_ca_signing_token=
5348b8
 
5348b8
 # DEPRECATED: Use 'pki_ca_signing_csr_path' instead.
5348b8
-pki_external_csr_path=%(pki_instance_configuration_path)s/external_ca.csr
5348b8
+pki_external_csr_path=
5348b8
 pki_ca_signing_csr_path=%(pki_external_csr_path)s
5348b8
 
5348b8
 pki_ocsp_signing_csr_path=
5348b8
@@ -442,12 +442,12 @@ pki_kra_ephemeral_requests=False
5348b8
 
5348b8
 # DEPRECATED
5348b8
 # Use 'pki_*_csr_path' instead.
5348b8
-pki_external_admin_csr_path=%(pki_instance_configuration_path)s/%(pki_subsystem_type)s_admin.csr
5348b8
-pki_external_audit_signing_csr_path=%(pki_instance_configuration_path)s/%(pki_subsystem_type)s_audit_signing.csr
5348b8
-pki_external_sslserver_csr_path=%(pki_instance_configuration_path)s/%(pki_subsystem_type)s_sslserver.csr
5348b8
-pki_external_storage_csr_path=%(pki_instance_configuration_path)s/%(pki_subsystem_type)s_storage.csr
5348b8
-pki_external_subsystem_csr_path=%(pki_instance_configuration_path)s/%(pki_subsystem_type)s_subsystem.csr
5348b8
-pki_external_transport_csr_path=%(pki_instance_configuration_path)s/%(pki_subsystem_type)s_transport.csr
5348b8
+pki_external_admin_csr_path=
5348b8
+pki_external_audit_signing_csr_path=
5348b8
+pki_external_sslserver_csr_path=
5348b8
+pki_external_storage_csr_path=
5348b8
+pki_external_subsystem_csr_path=
5348b8
+pki_external_transport_csr_path=
5348b8
 
5348b8
 pki_admin_csr_path=%(pki_external_admin_csr_path)s
5348b8
 pki_audit_signing_csr_path=%(pki_external_audit_signing_csr_path)s
5348b8
@@ -527,11 +527,11 @@ pki_standalone=False
5348b8
 
5348b8
 # DEPRECATED
5348b8
 # Use 'pki_*_csr_path' instead.
5348b8
-pki_external_admin_csr_path=%(pki_instance_configuration_path)s/%(pki_subsystem_type)s_admin.csr
5348b8
-pki_external_audit_signing_csr_path=%(pki_instance_configuration_path)s/%(pki_subsystem_type)s_audit_signing.csr
5348b8
-pki_external_signing_csr_path=%(pki_instance_configuration_path)s/%(pki_subsystem_type)s_signing.csr
5348b8
-pki_external_sslserver_csr_path=%(pki_instance_configuration_path)s/%(pki_subsystem_type)s_sslserver.csr
5348b8
-pki_external_subsystem_csr_path=%(pki_instance_configuration_path)s/%(pki_subsystem_type)s_subsystem.csr
5348b8
+pki_external_admin_csr_path=
5348b8
+pki_external_audit_signing_csr_path=
5348b8
+pki_external_signing_csr_path=
5348b8
+pki_external_sslserver_csr_path=
5348b8
+pki_external_subsystem_csr_path=
5348b8
 
5348b8
 pki_admin_csr_path=%(pki_external_admin_csr_path)s
5348b8
 pki_audit_signing_csr_path=%(pki_external_audit_signing_csr_path)s
5348b8
diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py
5348b8
index 3b55f78..b3c3ccb 100644
5348b8
--- a/base/server/python/pki/server/deployment/pkihelper.py
5348b8
+++ b/base/server/python/pki/server/deployment/pkihelper.py
5348b8
@@ -712,39 +712,9 @@ class ConfigurationFile:
5348b8
                 # pki_ca_signing_cert_path are optional.
5348b8
                 pass
5348b8
         elif not self.skip_configuration and self.standalone:
5348b8
-            if not self.external_step_two:
5348b8
-
5348b8
-                # Stand-alone PKI Admin CSR (Step 1)
5348b8
-                self.confirm_data_exists("pki_admin_csr_path")
5348b8
-
5348b8
-                # Stand-alone PKI Audit Signing CSR (Step 1)
5348b8
-                self.confirm_data_exists(
5348b8
-                    "pki_audit_signing_csr_path")
5348b8
 
5348b8
-                # Stand-alone PKI SSL Server CSR (Step 1)
5348b8
-                self.confirm_data_exists("pki_sslserver_csr_path")
5348b8
+            if self.external_step_two:
5348b8
 
5348b8
-                # Stand-alone PKI Subsystem CSR (Step 1)
5348b8
-                self.confirm_data_exists("pki_subsystem_csr_path")
5348b8
-
5348b8
-                # Stand-alone PKI KRA CSRs
5348b8
-                if self.subsystem == "KRA":
5348b8
-
5348b8
-                    # Stand-alone PKI KRA Storage CSR (Step 1)
5348b8
-                    self.confirm_data_exists(
5348b8
-                        "pki_storage_csr_path")
5348b8
-
5348b8
-                    # Stand-alone PKI KRA Transport CSR (Step 1)
5348b8
-                    self.confirm_data_exists(
5348b8
-                        "pki_transport_csr_path")
5348b8
-
5348b8
-                # Stand-alone PKI OCSP CSRs
5348b8
-                if self.subsystem == "OCSP":
5348b8
-                    # Stand-alone PKI OCSP OCSP Signing CSR (Step 1)
5348b8
-                    self.confirm_data_exists(
5348b8
-                        "pki_ocsp_signing_csr_path")
5348b8
-
5348b8
-            else:
5348b8
                 # Stand-alone PKI External CA Certificate (Step 2)
5348b8
                 # The pki_ca_signing_cert_path is optional.
5348b8
 
5348b8
-- 
5348b8
1.8.3.1
5348b8
5348b8
5348b8
From e2563b186203e5e89d281ff5c39ca182f62cfefa Mon Sep 17 00:00:00 2001
5348b8
From: "Endi S. Dewata" <edewata@redhat.com>
5348b8
Date: Tue, 21 Aug 2018 01:03:11 +0200
5348b8
Subject: [PATCH 06/13] Added support for installation with custom CSRs
5348b8
5348b8
The installation code has been modified to import custom
5348b8
CSRs for KRA and OCSP system certicates if provided. The
5348b8
CA installation already supports this functionality.
5348b8
5348b8
https://pagure.io/dogtagpki/issue/3053
5348b8
5348b8
Change-Id: Ic6a7a462bf07f2ca07275a01fc04b8d194005188
5348b8
(cherry picked from commit 88271a9b3d829669fb997ee6158081da18faed97)
5348b8
---
5348b8
 .../netscape/cms/servlet/csadmin/ConfigurationUtils.java | 11 +++--------
5348b8
 .../pki/server/deployment/scriptlets/configuration.py    | 16 ++++++++++++----
5348b8
 2 files changed, 15 insertions(+), 12 deletions(-)
5348b8
5348b8
diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
5348b8
index d8b4965..7398891 100644
5348b8
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
5348b8
+++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
5348b8
@@ -2986,14 +2986,9 @@ public class ConfigurationUtils {
5348b8
 
5348b8
         CMS.debug("ConfigurationUtils.loadCertRequest(" + tag + ")");
5348b8
 
5348b8
-        try {
5348b8
-            String certreq = config.getString(subsystem + "." + tag + ".certreq");
5348b8
-            return CryptoUtil.base64Decode(certreq);
5348b8
-
5348b8
-        } catch (EPropertyNotFound e) {
5348b8
-            // The CSR is optional for existing CA case.
5348b8
-            return null;
5348b8
-        }
5348b8
+        // the CSR must exist in the second step of external CA scenario
5348b8
+        String certreq = config.getString(subsystem + "." + tag + ".certreq");
5348b8
+        return CryptoUtil.base64Decode(certreq);
5348b8
     }
5348b8
 
5348b8
     public static void generateCertRequest(IConfigStore config, String certTag, Cert cert) throws Exception {
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/configuration.py b/base/server/python/pki/server/deployment/scriptlets/configuration.py
5348b8
index 7bc0023..cf02205 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/configuration.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/configuration.py
5348b8
@@ -368,7 +368,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
             csr_data = f.read()
5348b8
 
5348b8
         b64_csr = pki.nssdb.convert_csr(csr_data, 'pem', 'base64')
5348b8
-        subsystem.config['ca.%s.certreq' % tag] = b64_csr
5348b8
+        subsystem.config['%s.%s.certreq' % (subsystem.name, tag)] = b64_csr
5348b8
 
5348b8
     def import_ca_signing_csr(self, deployer, subsystem):
5348b8
 
5348b8
@@ -391,9 +391,17 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
         if subsystem.name == 'ca':
5348b8
             self.import_ca_signing_csr(deployer, subsystem)
5348b8
             self.import_system_cert_request(deployer, subsystem, 'ocsp_signing')
5348b8
-            self.import_system_cert_request(deployer, subsystem, 'audit_signing')
5348b8
-            self.import_system_cert_request(deployer, subsystem, 'subsystem')
5348b8
-            self.import_system_cert_request(deployer, subsystem, 'sslserver')
5348b8
+
5348b8
+        if subsystem.name == 'kra':
5348b8
+            self.import_system_cert_request(deployer, subsystem, 'storage')
5348b8
+            self.import_system_cert_request(deployer, subsystem, 'transport')
5348b8
+
5348b8
+        if subsystem.name == 'ocsp':
5348b8
+            self.import_system_cert_request(deployer, subsystem, 'signing')
5348b8
+
5348b8
+        self.import_system_cert_request(deployer, subsystem, 'audit_signing')
5348b8
+        self.import_system_cert_request(deployer, subsystem, 'subsystem')
5348b8
+        self.import_system_cert_request(deployer, subsystem, 'sslserver')
5348b8
 
5348b8
     def import_ca_signing_cert(self, deployer, nssdb):
5348b8
 
5348b8
-- 
5348b8
1.8.3.1
5348b8
5348b8
5348b8
From e3b8099fb20b6806020bab1a1687340da643eacf Mon Sep 17 00:00:00 2001
5348b8
From: "Endi S. Dewata" <edewata@redhat.com>
5348b8
Date: Tue, 21 Aug 2018 20:01:30 +0200
5348b8
Subject: [PATCH 07/13] Fixed messages for installation with custom keys
5348b8
5348b8
The pkispawn has been modified to display the proper message
5348b8
for installation with custom keys where the CSRs will not be
5348b8
generated.
5348b8
5348b8
https://pagure.io/dogtagpki/issue/3053
5348b8
5348b8
Change-Id: Ibd0ae62c88c2b10520231de3e485e305c715218c
5348b8
(cherry picked from commit e50f3b0b6034c2c18a0775f2e91fd2e5ea21678f)
5348b8
---
5348b8
 base/server/sbin/pkispawn | 81 +++++++++++++++++++++++++++++++++++++----------
5348b8
 1 file changed, 65 insertions(+), 16 deletions(-)
5348b8
5348b8
diff --git a/base/server/sbin/pkispawn b/base/server/sbin/pkispawn
5348b8
index ab94b8b..64c7a67 100755
5348b8
--- a/base/server/sbin/pkispawn
5348b8
+++ b/base/server/sbin/pkispawn
5348b8
@@ -760,9 +760,17 @@ def print_external_ca_step_one_information(mdict):
5348b8
     print("      The %s subsystem of the '%s' instance is still incomplete." %
5348b8
           (deployer.subsystem_name, mdict['pki_instance_name']))
5348b8
     print()
5348b8
-    print("      A CSR for the CA certificate has been generated at:\n"
5348b8
-          "            %s"
5348b8
-          % mdict['pki_ca_signing_csr_path'])
5348b8
+    print("      NSS database: %s" % mdict['pki_database_path'])
5348b8
+    print()
5348b8
+
5348b8
+    signing_csr = mdict['pki_ca_signing_csr_path']
5348b8
+
5348b8
+    if signing_csr:
5348b8
+        print("      A CSR for the CA signing certificate has been generated in:")
5348b8
+        print("            %s" % mdict['pki_ca_signing_csr_path'])
5348b8
+    else:
5348b8
+        print("      No CSR has been generated for CA signing certificate.")
5348b8
+
5348b8
     print(log.PKI_RUN_INSTALLATION_STEP_TWO)
5348b8
     print(log.PKI_SPAWN_INFORMATION_FOOTER)
5348b8
 
5348b8
@@ -773,13 +781,35 @@ def print_kra_step_one_information(mdict):
5348b8
     print("      The %s subsystem of the '%s' instance is still incomplete." %
5348b8
           (deployer.subsystem_name, mdict['pki_instance_name']))
5348b8
     print()
5348b8
-    print("      The CSRs for KRA certificates have been generated in:")
5348b8
-    print("          storage:       %s" % mdict['pki_storage_csr_path'])
5348b8
-    print("          transport:     %s" % mdict['pki_transport_csr_path'])
5348b8
-    print("          subsystem:     %s" % mdict['pki_subsystem_csr_path'])
5348b8
-    print("          SSL server:    %s" % mdict['pki_sslserver_csr_path'])
5348b8
-    print("          audit signing: %s" % mdict['pki_audit_signing_csr_path'])
5348b8
-    print("          admin:         %s" % mdict['pki_admin_csr_path'])
5348b8
+    print("      NSS database: %s" % mdict['pki_database_path'])
5348b8
+    print()
5348b8
+
5348b8
+    storage_csr = mdict['pki_storage_csr_path']
5348b8
+    transport_csr = mdict['pki_transport_csr_path']
5348b8
+    subsystem_csr = mdict['pki_subsystem_csr_path']
5348b8
+    sslserver_csr = mdict['pki_sslserver_csr_path']
5348b8
+    audit_csr = mdict['pki_audit_signing_csr_path']
5348b8
+    admin_csr = mdict['pki_admin_csr_path']
5348b8
+
5348b8
+    if storage_csr or transport_csr or subsystem_csr or sslserver_csr \
5348b8
+            or audit_csr or admin_csr:
5348b8
+        print("      The CSRs for KRA certificates have been generated in:")
5348b8
+    else:
5348b8
+        print("      No CSRs have been generated for KRA certificates.")
5348b8
+
5348b8
+    if storage_csr:
5348b8
+        print("          storage:       %s" % storage_csr)
5348b8
+    if transport_csr:
5348b8
+        print("          transport:     %s" % transport_csr)
5348b8
+    if subsystem_csr:
5348b8
+        print("          subsystem:     %s" % subsystem_csr)
5348b8
+    if sslserver_csr:
5348b8
+        print("          SSL server:    %s" % sslserver_csr)
5348b8
+    if audit_csr:
5348b8
+        print("          audit signing: %s" % audit_csr)
5348b8
+    if admin_csr:
5348b8
+        print("          admin:         %s" % admin_csr)
5348b8
+
5348b8
     print(log.PKI_RUN_INSTALLATION_STEP_TWO)
5348b8
     print(log.PKI_SPAWN_INFORMATION_FOOTER)
5348b8
 
5348b8
@@ -790,12 +820,31 @@ def print_ocsp_step_one_information(mdict):
5348b8
     print("      The %s subsystem of the '%s' instance is still incomplete." %
5348b8
           (deployer.subsystem_name, mdict['pki_instance_name']))
5348b8
     print()
5348b8
-    print("      The CSRs for OCSP certificates have been generated in:")
5348b8
-    print("          OCSP signing:  %s" % mdict['pki_ocsp_signing_csr_path'])
5348b8
-    print("          subsystem:     %s" % mdict['pki_subsystem_csr_path'])
5348b8
-    print("          SSL server:    %s" % mdict['pki_sslserver_csr_path'])
5348b8
-    print("          audit signing: %s" % mdict['pki_audit_signing_csr_path'])
5348b8
-    print("          admin:         %s" % mdict['pki_admin_csr_path'])
5348b8
+    print("      NSS database: %s" % mdict['pki_database_path'])
5348b8
+    print()
5348b8
+
5348b8
+    signing_csr = mdict['pki_ocsp_signing_csr_path']
5348b8
+    subsystem_csr = mdict['pki_subsystem_csr_path']
5348b8
+    sslserver_csr = mdict['pki_sslserver_csr_path']
5348b8
+    audit_csr = mdict['pki_audit_signing_csr_path']
5348b8
+    admin_csr = mdict['pki_admin_csr_path']
5348b8
+
5348b8
+    if signing_csr or subsystem_csr or sslserver_csr or audit_csr or admin_csr:
5348b8
+        print("      The CSRs for OCSP certificates have been generated in:")
5348b8
+    else:
5348b8
+        print("      No CSRs have been generated for OCSP certificates.")
5348b8
+
5348b8
+    if signing_csr:
5348b8
+        print("          OCSP signing:  %s" % signing_csr)
5348b8
+    if subsystem_csr:
5348b8
+        print("          subsystem:     %s" % subsystem_csr)
5348b8
+    if sslserver_csr:
5348b8
+        print("          SSL server:    %s" % sslserver_csr)
5348b8
+    if audit_csr:
5348b8
+        print("          audit signing: %s" % audit_csr)
5348b8
+    if admin_csr:
5348b8
+        print("          admin:         %s" % admin_csr)
5348b8
+
5348b8
     print(log.PKI_RUN_INSTALLATION_STEP_TWO)
5348b8
     print(log.PKI_SPAWN_INFORMATION_FOOTER)
5348b8
 
5348b8
-- 
5348b8
1.8.3.1
5348b8
5348b8
5348b8
From 6c7079adf8878a2c799cd716c3df9ec75816accd Mon Sep 17 00:00:00 2001
5348b8
From: "Endi S. Dewata" <edewata@redhat.com>
5348b8
Date: Thu, 23 Aug 2018 06:10:44 +0200
5348b8
Subject: [PATCH 08/13] Fixed pki client-cert-import to accept PKCS #7 CA cert
5348b8
 chain
5348b8
5348b8
The NSSDatabase.add_cert() has been modified to accept both single
5348b8
certificates and PKCS #7 certificate chains in PEM format.
5348b8
5348b8
The pki client-cert-import has been modified to support importing
5348b8
CA cert chain in PKCS #7 format.
5348b8
5348b8
The Cert.parseCertificate() has been modified to parse PKCS #7
5348b8
cert chain properly.
5348b8
5348b8
https://pagure.io/dogtagpki/issue/3053
5348b8
5348b8
Change-Id: Ibeffcfa4915638df7b13a0cb6deb8c4afc775ca1
5348b8
(cherry picked from commit 9cef57869f01e89653331c0e22c9d3bacf7744ce)
5348b8
---
5348b8
 base/common/python/pki/nssdb.py                            |  2 ++
5348b8
 .../com/netscape/cmstools/client/ClientCertImportCLI.java  | 14 +++++++++++---
5348b8
 base/util/src/com/netscape/cmsutil/util/Cert.java          | 12 +++++++++---
5348b8
 3 files changed, 22 insertions(+), 6 deletions(-)
5348b8
5348b8
diff --git a/base/common/python/pki/nssdb.py b/base/common/python/pki/nssdb.py
5348b8
index d4ae804..05d2c62 100644
5348b8
--- a/base/common/python/pki/nssdb.py
5348b8
+++ b/base/common/python/pki/nssdb.py
5348b8
@@ -223,6 +223,7 @@ class NSSDatabase(object):
5348b8
                 '-P', self.token,
5348b8
                 '-f', self.password_file,
5348b8
                 '-n', nickname,
5348b8
+                '-a',
5348b8
                 '-i', cert_file,
5348b8
                 '-t', ''
5348b8
             ]
5348b8
@@ -242,6 +243,7 @@ class NSSDatabase(object):
5348b8
                 '-d', self.directory,
5348b8
                 '-f', self.internal_password_file,
5348b8
                 '-n', nickname,
5348b8
+                '-a',
5348b8
                 '-i', cert_file,
5348b8
                 '-t', trust_attributes
5348b8
             ]
5348b8
diff --git a/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java b/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java
5348b8
index 99b215e..62fd4d6 100644
5348b8
--- a/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java
5348b8
+++ b/base/java-tools/src/com/netscape/cmstools/client/ClientCertImportCLI.java
5348b8
@@ -19,7 +19,6 @@
5348b8
 package com.netscape.cmstools.client;
5348b8
 
5348b8
 import java.io.File;
5348b8
-import java.io.FileOutputStream;
5348b8
 import java.io.FileWriter;
5348b8
 import java.io.PrintWriter;
5348b8
 import java.net.URI;
5348b8
@@ -45,6 +44,7 @@ import com.netscape.cmstools.cli.CLI;
5348b8
 import com.netscape.cmstools.cli.MainCLI;
5348b8
 import com.netscape.cmsutil.crypto.CryptoUtil;
5348b8
 import com.netscape.cmsutil.util.Cert;
5348b8
+import com.netscape.cmsutil.util.Utils;
5348b8
 
5348b8
 import netscape.security.pkcs.PKCS12;
5348b8
 import netscape.security.pkcs.PKCS7;
5348b8
@@ -250,8 +250,11 @@ public class ClientCertImportCLI extends CLI {
5348b8
             File certFile = File.createTempFile("pki-client-cert-import-", ".crt");
5348b8
             certFile.deleteOnExit();
5348b8
 
5348b8
-            try (FileOutputStream out = new FileOutputStream(certFile)) {
5348b8
-                out.write(bytes);
5348b8
+            try (FileWriter fw = new FileWriter(certFile);
5348b8
+                    PrintWriter out = new PrintWriter(fw)) {
5348b8
+                out.println(PKCS7.HEADER);
5348b8
+                out.print(Utils.base64encode(bytes, true));
5348b8
+                out.println(PKCS7.FOOTER);
5348b8
             }
5348b8
 
5348b8
             if (trustAttributes == null)
5348b8
@@ -338,6 +341,9 @@ public class ClientCertImportCLI extends CLI {
5348b8
             command.add(dbPasswordFile.getAbsolutePath());
5348b8
         }
5348b8
 
5348b8
+        // accept PEM or PKCS #7 certificate
5348b8
+        command.add("-a");
5348b8
+
5348b8
         command.add("-i");
5348b8
         command.add(certFile);
5348b8
         command.add("-n");
5348b8
@@ -362,10 +368,12 @@ public class ClientCertImportCLI extends CLI {
5348b8
             String trustAttributes) throws Exception {
5348b8
 
5348b8
         if (nickname != null) {
5348b8
+            // import a single CA certificate with the provided nickname
5348b8
             importCert(dbPath, dbPasswordFile, certFile, nickname, trustAttributes);
5348b8
             return;
5348b8
         }
5348b8
 
5348b8
+        // import CA certificate chain with auto-generated nicknames
5348b8
         String pemCert = new String(Files.readAllBytes(Paths.get(certFile))).trim();
5348b8
         byte[] binCert = Cert.parseCertificate(pemCert);
5348b8
 
5348b8
diff --git a/base/util/src/com/netscape/cmsutil/util/Cert.java b/base/util/src/com/netscape/cmsutil/util/Cert.java
5348b8
index f084395..e6f2460 100644
5348b8
--- a/base/util/src/com/netscape/cmsutil/util/Cert.java
5348b8
+++ b/base/util/src/com/netscape/cmsutil/util/Cert.java
5348b8
@@ -33,6 +33,9 @@ public class Cert {
5348b8
     public static final String HEADER = "-----BEGIN CERTIFICATE-----";
5348b8
     public static final String FOOTER = "-----END CERTIFICATE-----";
5348b8
 
5348b8
+    public static final String PKCS7_HEADER = "-----BEGIN PKCS7-----";
5348b8
+    public static final String PKCS7_FOOTER = "-----END PKCS7-----";
5348b8
+
5348b8
     // From https://www.rfc-editor.org/rfc/rfc7468.txt
5348b8
     public static final String REQUEST_HEADER = "-----BEGIN CERTIFICATE REQUEST-----";
5348b8
     public static final String REQUEST_FOOTER = "-----END CERTIFICATE REQUEST-----";
5348b8
@@ -68,9 +71,12 @@ public class Cert {
5348b8
             return s;
5348b8
         }
5348b8
 
5348b8
-        if ((s.startsWith(HEADER)) &&
5348b8
-                (s.endsWith(FOOTER))) {
5348b8
-            return (s.substring(27, (s.length() - 25)));
5348b8
+        if (s.startsWith(HEADER) && s.endsWith(FOOTER)) {
5348b8
+            return s.substring(HEADER.length(), s.length() - FOOTER.length());
5348b8
+        }
5348b8
+
5348b8
+        if (s.startsWith(PKCS7_HEADER) && s.endsWith(PKCS7_FOOTER)) {
5348b8
+            return s.substring(PKCS7_HEADER.length(), s.length() - PKCS7_FOOTER.length());
5348b8
         }
5348b8
 
5348b8
         // To support Thawte's header and footer
5348b8
-- 
5348b8
1.8.3.1
5348b8
5348b8
5348b8
From ea9b582909d10d8f6c485860615319b6f6c31741 Mon Sep 17 00:00:00 2001
5348b8
From: "Endi S. Dewata" <edewata@redhat.com>
5348b8
Date: Fri, 31 Aug 2018 00:32:44 +0200
5348b8
Subject: [PATCH 09/13] Renamed server NSS database parameters
5348b8
5348b8
The following parameters have been renamed for consistency:
5348b8
* pki_database_path -> pki_server_database_path
5348b8
* pki_pin -> pki_server_database_password
5348b8
5348b8
The old parameters are still usable but they have been
5348b8
deprecated.
5348b8
5348b8
The pki_client_pin is redundant so it has been removed.
5348b8
5348b8
https://pagure.io/dogtagpki/issue/3053
5348b8
5348b8
Change-Id: I243a01b360f573a16a160e9a415f786e38681603
5348b8
(cherry picked from commit 80defb1b7602eb59f5ee817a76acac86490ce853)
5348b8
---
5348b8
 base/server/etc/default.cfg                        | 10 ++++++-
5348b8
 .../python/pki/server/deployment/pkihelper.py      | 10 +++----
5348b8
 .../python/pki/server/deployment/pkiparser.py      | 34 +++++++++++++---------
5348b8
 .../server/deployment/scriptlets/configuration.py  |  4 +--
5348b8
 .../deployment/scriptlets/instance_layout.py       |  6 ++--
5348b8
 .../deployment/scriptlets/security_databases.py    | 21 ++++++-------
5348b8
 .../server/deployment/scriptlets/selinux_setup.py  |  8 ++---
5348b8
 base/server/sbin/pkispawn                          |  6 ++--
5348b8
 8 files changed, 57 insertions(+), 42 deletions(-)
5348b8
5348b8
diff --git a/base/server/etc/default.cfg b/base/server/etc/default.cfg
5348b8
index 2c0430a..0ae0764 100644
5348b8
--- a/base/server/etc/default.cfg
5348b8
+++ b/base/server/etc/default.cfg
5348b8
@@ -31,6 +31,7 @@ sensitive_parameters=
5348b8
     pki_pin
5348b8
     pki_replication_password
5348b8
     pki_security_domain_password
5348b8
+    pki_server_database_password
5348b8
     pki_server_pkcs12_password
5348b8
     pki_token_password
5348b8
 
5348b8
@@ -173,6 +174,14 @@ pki_cert_chain_path=%(pki_external_ca_cert_chain_path)s
5348b8
 pki_external_ca_cert_chain_nickname=caSigningCert External CA
5348b8
 pki_cert_chain_nickname=%(pki_external_ca_cert_chain_nickname)s
5348b8
 
5348b8
+# DEPRECATED: Use 'pki_server_database_path' instead.
5348b8
+pki_database_path=%(pki_instance_configuration_path)s/alias
5348b8
+pki_server_database_path=%(pki_database_path)s
5348b8
+
5348b8
+# DEPRECATED: Use 'pki_server_database_password' instead.
5348b8
+pki_pin=
5348b8
+pki_server_database_password=
5348b8
+
5348b8
 pki_pkcs12_path=
5348b8
 pki_pkcs12_password=
5348b8
 
5348b8
@@ -201,7 +210,6 @@ pki_registry_path=%(pki_root_prefix)s/etc/sysconfig/pki
5348b8
 pki_instance_path=%(pki_path)s/%(pki_instance_name)s
5348b8
 pki_instance_log_path=%(pki_log_path)s/%(pki_instance_name)s
5348b8
 pki_instance_configuration_path=%(pki_configuration_path)s/%(pki_instance_name)s
5348b8
-pki_database_path=%(pki_instance_configuration_path)s/alias
5348b8
 pki_instance_database_link=%(pki_instance_path)s/alias
5348b8
 pki_instance_conf_link=%(pki_instance_path)s/conf
5348b8
 pki_instance_logs_link=%(pki_instance_path)s/logs
5348b8
diff --git a/base/server/python/pki/server/deployment/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py
5348b8
index b3c3ccb..77594ec 100644
5348b8
--- a/base/server/python/pki/server/deployment/pkihelper.py
5348b8
+++ b/base/server/python/pki/server/deployment/pkihelper.py
5348b8
@@ -3092,7 +3092,7 @@ class KRAConnector:
5348b8
                    "-h", cahost,
5348b8
                    "-n", subsystemnick,
5348b8
                    "-P", "https",
5348b8
-                   "-d", self.mdict['pki_database_path'],
5348b8
+                   "-d", self.mdict['pki_server_database_path'],
5348b8
                    "-c", token_pwd,
5348b8
                    "ca-kraconnector-del",
5348b8
                    "--host", krahost,
5348b8
@@ -3125,7 +3125,7 @@ class KRAConnector:
5348b8
         command = ["/usr/bin/sslget",
5348b8
                    "-n", subsystemnick,
5348b8
                    "-p", token_pwd,
5348b8
-                   "-d", self.mdict['pki_database_path'],
5348b8
+                   "-d", self.mdict['pki_server_database_path'],
5348b8
                    "-e", params,
5348b8
                    "-v",
5348b8
                    "-r", update_url, cahost + ":" + str(caport)]
5348b8
@@ -3236,7 +3236,7 @@ class TPSConnector:
5348b8
                    "-h", tkshost,
5348b8
                    "-n", subsystemnick,
5348b8
                    "-P", "https",
5348b8
-                   "-d", self.mdict['pki_database_path'],
5348b8
+                   "-d", self.mdict['pki_server_database_path'],
5348b8
                    "-c", token_pwd,
5348b8
                    "-t", "tks",
5348b8
                    "tks-tpsconnector-del",
5348b8
@@ -3336,7 +3336,7 @@ class SecurityDomain:
5348b8
                 admin_update_url = "/ca/admin/ca/updateDomainXML"
5348b8
                 command = ["/usr/bin/sslget",
5348b8
                            "-p", str(123456),
5348b8
-                           "-d", self.mdict['pki_database_path'],
5348b8
+                           "-d", self.mdict['pki_server_database_path'],
5348b8
                            "-e", params,
5348b8
                            "-v",
5348b8
                            "-r", admin_update_url,
5348b8
@@ -3451,7 +3451,7 @@ class SecurityDomain:
5348b8
         command = ["/usr/bin/sslget",
5348b8
                    "-n", subsystemnick,
5348b8
                    "-p", token_pwd,
5348b8
-                   "-d", self.mdict['pki_database_path'],
5348b8
+                   "-d", self.mdict['pki_server_database_path'],
5348b8
                    "-e", params,
5348b8
                    "-v",
5348b8
                    "-r", update_url, sechost + ":" + str(secagentport)]
5348b8
diff --git a/base/server/python/pki/server/deployment/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py
5348b8
index 2397f43..5b8cdd3 100644
5348b8
--- a/base/server/python/pki/server/deployment/pkiparser.py
5348b8
+++ b/base/server/python/pki/server/deployment/pkiparser.py
5348b8
@@ -84,7 +84,11 @@ class PKIConfigParser:
5348b8
         (None, 'pki_ssl_server_subject_dn',
5348b8
          None, 'pki_sslserver_subject_dn'),
5348b8
         (None, 'pki_ssl_server_token',
5348b8
-         None, 'pki_sslserver_token')
5348b8
+         None, 'pki_sslserver_token'),
5348b8
+        (None, 'pki_database_path',
5348b8
+         None, 'pki_server_database_path'),
5348b8
+        (None, 'pki_pin',
5348b8
+         None, 'pki_server_database_password'),
5348b8
     ]
5348b8
 
5348b8
     DEPRECATED_CA_PARAMS = [
5348b8
@@ -490,6 +494,7 @@ class PKIConfigParser:
5348b8
                     'pki_pin',
5348b8
                     'pki_replication_password',
5348b8
                     'pki_security_domain_password',
5348b8
+                    'pki_server_database_password',
5348b8
                     'pki_server_pkcs12_password',
5348b8
                     'pki_token_password')
5348b8
 
5348b8
@@ -766,17 +771,23 @@ class PKIConfigParser:
5348b8
 
5348b8
             # if instance already exists and has password, reuse the password
5348b8
             if internal_token in instance.passwords:
5348b8
-                self.mdict['pki_pin'] = instance.passwords.get(internal_token)
5348b8
+                self.mdict['pki_server_database_password'] = instance.passwords.get(internal_token)
5348b8
 
5348b8
             # otherwise, use user-provided password if specified
5348b8
-            elif 'pki_pin' in self.mdict:
5348b8
+            elif self.mdict['pki_server_database_password']:
5348b8
                 pass
5348b8
 
5348b8
+            # otherwise, use user-provided pin if specified
5348b8
+            elif self.mdict['pki_pin']:
5348b8
+                self.mdict['pki_server_database_password'] = self.mdict['pki_pin']
5348b8
+
5348b8
             # otherwise, generate a random password
5348b8
             else:
5348b8
-                self.mdict['pki_pin'] = pki.generate_password()
5348b8
+                self.mdict['pki_server_database_password'] = pki.generate_password()
5348b8
 
5348b8
-            self.mdict['pki_client_pin'] = pki.generate_password()
5348b8
+            # generate random password for client database if not specified
5348b8
+            if not self.mdict['pki_client_database_password']:
5348b8
+                self.mdict['pki_client_database_password'] = pki.generate_password()
5348b8
 
5348b8
             pkilogging.sensitive_parameters = \
5348b8
                 self.mdict['sensitive_parameters'].split()
5348b8
@@ -1231,13 +1242,13 @@ class PKIConfigParser:
5348b8
                     self.mdict['pki_instance_configuration_path'],
5348b8
                     "password.conf")
5348b8
             self.mdict['pki_cert_database'] = \
5348b8
-                os.path.join(self.mdict['pki_database_path'],
5348b8
+                os.path.join(self.mdict['pki_server_database_path'],
5348b8
                              "cert8.db")
5348b8
             self.mdict['pki_key_database'] = \
5348b8
-                os.path.join(self.mdict['pki_database_path'],
5348b8
+                os.path.join(self.mdict['pki_server_database_path'],
5348b8
                              "key3.db")
5348b8
             self.mdict['pki_secmod_database'] = \
5348b8
-                os.path.join(self.mdict['pki_database_path'],
5348b8
+                os.path.join(self.mdict['pki_server_database_path'],
5348b8
                              "secmod.db")
5348b8
             self.mdict['pki_self_signed_nickname'] = \
5348b8
                 self.mdict['pki_sslserver_nickname']
5348b8
@@ -1262,11 +1273,6 @@ class PKIConfigParser:
5348b8
                     self.mdict['pki_subsystem_configuration_path'],
5348b8
                     "password.conf")
5348b8
 
5348b8
-            if not len(self.mdict['pki_client_database_password']):
5348b8
-                # use randomly generated client 'pin'
5348b8
-                self.mdict['pki_client_database_password'] = \
5348b8
-                    str(self.mdict['pki_client_pin'])
5348b8
-
5348b8
             # Configuration scriptlet
5348b8
             # 'Security Domain' Configuration name/value pairs
5348b8
             # 'Subsystem Name'  Configuration name/value pairs
5348b8
@@ -1393,7 +1399,7 @@ class PKIConfigParser:
5348b8
                 # NOTE:  ALWAYS store the PKCS #12 backup keys file
5348b8
                 #        in with the NSS "server" security databases
5348b8
                 self.mdict['pki_backup_keys_p12'] = \
5348b8
-                    self.mdict['pki_database_path'] + "/" + \
5348b8
+                    self.mdict['pki_server_database_path'] + "/" + \
5348b8
                     self.mdict['pki_subsystem'].lower() + "_" + \
5348b8
                     "backup" + "_" + "keys" + "." + "p12"
5348b8
 
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/configuration.py b/base/server/python/pki/server/deployment/scriptlets/configuration.py
5348b8
index cf02205..f085e80 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/configuration.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/configuration.py
5348b8
@@ -865,7 +865,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
 
5348b8
             deployer.password.create_password_conf(
5348b8
                 deployer.mdict['pki_shared_pfile'],
5348b8
-                deployer.mdict['pki_pin'], pin_sans_token=True)
5348b8
+                deployer.mdict['pki_server_database_password'], pin_sans_token=True)
5348b8
 
5348b8
             # only create a self signed cert for a new instance
5348b8
             #
5348b8
@@ -884,7 +884,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
                 f.write("not_so_random_data")
5348b8
 
5348b8
             deployer.certutil.generate_self_signed_certificate(
5348b8
-                deployer.mdict['pki_database_path'],
5348b8
+                deployer.mdict['pki_server_database_path'],
5348b8
                 deployer.mdict['pki_cert_database'],
5348b8
                 deployer.mdict['pki_key_database'],
5348b8
                 deployer.mdict['pki_secmod_database'],
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/instance_layout.py b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
5348b8
index 568c0a0..e5ce820 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
5348b8
@@ -162,10 +162,10 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
         deployer.systemd.daemon_reload()
5348b8
 
5348b8
         # establish shared NSS security databases for this instance
5348b8
-        deployer.directory.create(deployer.mdict['pki_database_path'])
5348b8
+        deployer.directory.create(deployer.mdict['pki_server_database_path'])
5348b8
         # establish instance convenience symbolic links
5348b8
         deployer.symlink.create(
5348b8
-            deployer.mdict['pki_database_path'],
5348b8
+            deployer.mdict['pki_server_database_path'],
5348b8
             deployer.mdict['pki_instance_database_link'])
5348b8
         deployer.symlink.create(
5348b8
             deployer.mdict['pki_instance_configuration_path'],
5348b8
@@ -205,7 +205,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
             deployer.directory.delete(deployer.mdict['pki_instance_log_path'])
5348b8
 
5348b8
         # remove shared NSS security database path for this instance
5348b8
-        deployer.directory.delete(deployer.mdict['pki_database_path'])
5348b8
+        deployer.directory.delete(deployer.mdict['pki_server_database_path'])
5348b8
         # remove Tomcat instance configuration
5348b8
         deployer.directory.delete(
5348b8
             deployer.mdict['pki_instance_configuration_path'])
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/security_databases.py b/base/server/python/pki/server/deployment/scriptlets/security_databases.py
5348b8
index 02f4713..7ce32a8 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/security_databases.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/security_databases.py
5348b8
@@ -54,12 +54,12 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
         if config.str2bool(deployer.mdict['pki_hsm_enable']):
5348b8
             deployer.password.create_hsm_password_conf(
5348b8
                 deployer.mdict['pki_shared_password_conf'],
5348b8
-                deployer.mdict['pki_pin'],
5348b8
+                deployer.mdict['pki_server_database_password'],
5348b8
                 deployer.mdict['pki_token_password'])
5348b8
         else:
5348b8
             deployer.password.create_password_conf(
5348b8
                 deployer.mdict['pki_shared_password_conf'],
5348b8
-                deployer.mdict['pki_pin'])
5348b8
+                deployer.mdict['pki_server_database_password'])
5348b8
 
5348b8
         # Since 'certutil' does NOT strip the 'token=' portion of
5348b8
         # the 'token=password' entries, create a temporary server 'pfile'
5348b8
@@ -67,11 +67,11 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
         # allowing 'certutil' to generate the security databases
5348b8
         deployer.password.create_password_conf(
5348b8
             deployer.mdict['pki_shared_pfile'],
5348b8
-            deployer.mdict['pki_pin'], pin_sans_token=True)
5348b8
+            deployer.mdict['pki_server_database_password'], pin_sans_token=True)
5348b8
         deployer.file.modify(deployer.mdict['pki_shared_password_conf'])
5348b8
 
5348b8
         deployer.certutil.create_security_databases(
5348b8
-            deployer.mdict['pki_database_path'],
5348b8
+            deployer.mdict['pki_server_database_path'],
5348b8
             deployer.mdict['pki_cert_database'],
5348b8
             deployer.mdict['pki_key_database'],
5348b8
             deployer.mdict['pki_secmod_database'],
5348b8
@@ -79,7 +79,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
 
5348b8
         if config.str2bool(deployer.mdict['pki_hsm_enable']):
5348b8
             deployer.modutil.register_security_module(
5348b8
-                deployer.mdict['pki_database_path'],
5348b8
+                deployer.mdict['pki_server_database_path'],
5348b8
                 deployer.mdict['pki_hsm_modulename'],
5348b8
                 deployer.mdict['pki_hsm_libfile'])
5348b8
         deployer.file.modify(
5348b8
@@ -103,7 +103,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
                 raise Exception('Missing pki_server_pkcs12_password property.')
5348b8
 
5348b8
             nssdb = pki.nssdb.NSSDatabase(
5348b8
-                directory=deployer.mdict['pki_database_path'],
5348b8
+                directory=deployer.mdict['pki_server_database_path'],
5348b8
                 password_file=deployer.mdict['pki_shared_pfile'])
5348b8
 
5348b8
             try:
5348b8
@@ -129,7 +129,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
                 raise Exception('Missing pki_clone_pkcs12_password property.')
5348b8
 
5348b8
             nssdb = pki.nssdb.NSSDatabase(
5348b8
-                directory=deployer.mdict['pki_database_path'],
5348b8
+                directory=deployer.mdict['pki_server_database_path'],
5348b8
                 password_file=deployer.mdict['pki_shared_pfile'])
5348b8
 
5348b8
             try:
5348b8
@@ -162,7 +162,8 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
                     nickname=deployer.mdict['pki_audit_signing_nickname'],
5348b8
                     trust_attributes='u,u,Pu')
5348b8
 
5348b8
-                print('Imported certificates in %s:' % deployer.mdict['pki_database_path'])
5348b8
+                print('Imported certificates into %s:' %
5348b8
+                      deployer.mdict['pki_server_database_path'])
5348b8
 
5348b8
                 nssdb.show_certs()
5348b8
 
5348b8
@@ -180,7 +181,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
                 #        the instance will utilize 'softokn' or an HSM
5348b8
                 #
5348b8
                 rv = deployer.certutil.verify_certificate_exists(
5348b8
-                    deployer.mdict['pki_database_path'],
5348b8
+                    deployer.mdict['pki_server_database_path'],
5348b8
                     deployer.mdict['pki_cert_database'],
5348b8
                     deployer.mdict['pki_key_database'],
5348b8
                     deployer.mdict['pki_secmod_database'],
5348b8
@@ -195,7 +196,7 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
                             'pki_ds_secure_connection_ca_trustargs'],
5348b8
                         deployer.mdict['pki_ds_secure_connection_ca_pem_file'],
5348b8
                         password_file=deployer.mdict['pki_shared_pfile'],
5348b8
-                        path=deployer.mdict['pki_database_path'],
5348b8
+                        path=deployer.mdict['pki_server_database_path'],
5348b8
                         token=deployer.mdict['pki_self_signed_token'])
5348b8
 
5348b8
         # Always delete the temporary 'pfile'
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py b/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py
5348b8
index d5e4b0c..7d324d4 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py
5348b8
@@ -115,10 +115,10 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
 
5348b8
                         config.pki_log.info(
5348b8
                             "adding selinux fcontext \"%s\"",
5348b8
-                            deployer.mdict['pki_database_path'] + self.suffix,
5348b8
+                            deployer.mdict['pki_server_database_path'] + self.suffix,
5348b8
                             extra=config.PKI_INDENTATION_LEVEL_2)
5348b8
                         fcon.add(
5348b8
-                            deployer.mdict['pki_database_path'] + self.suffix,
5348b8
+                            deployer.mdict['pki_server_database_path'] + self.suffix,
5348b8
                             config.PKI_CERTDB_SELINUX_CONTEXT, "", "s0", "")
5348b8
 
5348b8
                         port_records = seobject.portRecords(trans)
5348b8
@@ -206,10 +206,10 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
 
5348b8
                         config.pki_log.info(
5348b8
                             "deleting selinux fcontext \"%s\"",
5348b8
-                            deployer.mdict['pki_database_path'] + self.suffix,
5348b8
+                            deployer.mdict['pki_server_database_path'] + self.suffix,
5348b8
                             extra=config.PKI_INDENTATION_LEVEL_2)
5348b8
                         fcon.delete(
5348b8
-                            deployer.mdict['pki_database_path'] +
5348b8
+                            deployer.mdict['pki_server_database_path'] +
5348b8
                             self.suffix, "")
5348b8
 
5348b8
                         port_records = seobject.portRecords(trans)
5348b8
diff --git a/base/server/sbin/pkispawn b/base/server/sbin/pkispawn
5348b8
index 64c7a67..867a381 100755
5348b8
--- a/base/server/sbin/pkispawn
5348b8
+++ b/base/server/sbin/pkispawn
5348b8
@@ -760,7 +760,7 @@ def print_external_ca_step_one_information(mdict):
5348b8
     print("      The %s subsystem of the '%s' instance is still incomplete." %
5348b8
           (deployer.subsystem_name, mdict['pki_instance_name']))
5348b8
     print()
5348b8
-    print("      NSS database: %s" % mdict['pki_database_path'])
5348b8
+    print("      NSS database: %s" % mdict['pki_server_database_path'])
5348b8
     print()
5348b8
 
5348b8
     signing_csr = mdict['pki_ca_signing_csr_path']
5348b8
@@ -781,7 +781,7 @@ def print_kra_step_one_information(mdict):
5348b8
     print("      The %s subsystem of the '%s' instance is still incomplete." %
5348b8
           (deployer.subsystem_name, mdict['pki_instance_name']))
5348b8
     print()
5348b8
-    print("      NSS database: %s" % mdict['pki_database_path'])
5348b8
+    print("      NSS database: %s" % mdict['pki_server_database_path'])
5348b8
     print()
5348b8
 
5348b8
     storage_csr = mdict['pki_storage_csr_path']
5348b8
@@ -820,7 +820,7 @@ def print_ocsp_step_one_information(mdict):
5348b8
     print("      The %s subsystem of the '%s' instance is still incomplete." %
5348b8
           (deployer.subsystem_name, mdict['pki_instance_name']))
5348b8
     print()
5348b8
-    print("      NSS database: %s" % mdict['pki_database_path'])
5348b8
+    print("      NSS database: %s" % mdict['pki_server_database_path'])
5348b8
     print()
5348b8
 
5348b8
     signing_csr = mdict['pki_ocsp_signing_csr_path']
5348b8
-- 
5348b8
1.8.3.1
5348b8
5348b8
5348b8
From a3d27ed43b9c119cfaff100573d89c2caa08e3b7 Mon Sep 17 00:00:00 2001
5348b8
From: "Endi S. Dewata" <edewata@redhat.com>
5348b8
Date: Fri, 7 Sep 2018 16:32:47 +0200
5348b8
Subject: [PATCH 10/13] Fixed password generation in pkispawn
5348b8
5348b8
Previously the NSS database passwords were generated in
5348b8
pkiparser.py. Under certain scenarios the password may be
5348b8
overwritten by a subsequent code in pkispawn. To avoid the
5348b8
problem the code that generates the NSS database passwords
5348b8
has been moved into the initialization scriptlet.
5348b8
5348b8
https://pagure.io/dogtagpki/issue/3061
5348b8
5348b8
Change-Id: Ieabfaea7465b615f214820d2ed877f4da589dadb
5348b8
(cherry picked from commit 9a984ee0a709645fe9b6044367ed28076692ee86)
5348b8
---
5348b8
 .../python/pki/server/deployment/pkiparser.py      | 25 --------------------
5348b8
 .../server/deployment/scriptlets/initialization.py | 27 ++++++++++++++++++++++
5348b8
 2 files changed, 27 insertions(+), 25 deletions(-)
5348b8
5348b8
diff --git a/base/server/python/pki/server/deployment/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py
5348b8
index 5b8cdd3..2ea7319 100644
5348b8
--- a/base/server/python/pki/server/deployment/pkiparser.py
5348b8
+++ b/base/server/python/pki/server/deployment/pkiparser.py
5348b8
@@ -764,31 +764,6 @@ class PKIConfigParser:
5348b8
 
5348b8
             self.deployer.flatten_master_dict()
5348b8
 
5348b8
-            instance = pki.server.PKIInstance(self.mdict['pki_instance_name'])
5348b8
-            instance.load()
5348b8
-
5348b8
-            internal_token = self.mdict['pki_self_signed_token']
5348b8
-
5348b8
-            # if instance already exists and has password, reuse the password
5348b8
-            if internal_token in instance.passwords:
5348b8
-                self.mdict['pki_server_database_password'] = instance.passwords.get(internal_token)
5348b8
-
5348b8
-            # otherwise, use user-provided password if specified
5348b8
-            elif self.mdict['pki_server_database_password']:
5348b8
-                pass
5348b8
-
5348b8
-            # otherwise, use user-provided pin if specified
5348b8
-            elif self.mdict['pki_pin']:
5348b8
-                self.mdict['pki_server_database_password'] = self.mdict['pki_pin']
5348b8
-
5348b8
-            # otherwise, generate a random password
5348b8
-            else:
5348b8
-                self.mdict['pki_server_database_password'] = pki.generate_password()
5348b8
-
5348b8
-            # generate random password for client database if not specified
5348b8
-            if not self.mdict['pki_client_database_password']:
5348b8
-                self.mdict['pki_client_database_password'] = pki.generate_password()
5348b8
-
5348b8
             pkilogging.sensitive_parameters = \
5348b8
                 self.mdict['sensitive_parameters'].split()
5348b8
 
5348b8
diff --git a/base/server/python/pki/server/deployment/scriptlets/initialization.py b/base/server/python/pki/server/deployment/scriptlets/initialization.py
5348b8
index efd1536..4515b55 100644
5348b8
--- a/base/server/python/pki/server/deployment/scriptlets/initialization.py
5348b8
+++ b/base/server/python/pki/server/deployment/scriptlets/initialization.py
5348b8
@@ -19,6 +19,7 @@
5348b8
 #
5348b8
 
5348b8
 from __future__ import absolute_import
5348b8
+import pki
5348b8
 
5348b8
 # PKI Deployment Imports
5348b8
 from .. import pkiconfig as config
5348b8
@@ -36,6 +37,32 @@ class PkiScriptlet(pkiscriptlet.AbstractBasePkiScriptlet):
5348b8
                             deployer.mdict['pki_subsystem'],
5348b8
                             deployer.mdict['pki_instance_name'],
5348b8
                             extra=config.PKI_INDENTATION_LEVEL_0)
5348b8
+
5348b8
+        instance = pki.server.PKIInstance(deployer.mdict['pki_instance_name'])
5348b8
+        instance.load()
5348b8
+
5348b8
+        internal_token = deployer.mdict['pki_self_signed_token']
5348b8
+
5348b8
+        # if instance already exists and has password, reuse the password
5348b8
+        if internal_token in instance.passwords:
5348b8
+            deployer.mdict['pki_server_database_password'] = instance.passwords.get(internal_token)
5348b8
+
5348b8
+        # otherwise, use user-provided password if specified
5348b8
+        elif deployer.mdict['pki_server_database_password']:
5348b8
+            pass
5348b8
+
5348b8
+        # otherwise, use user-provided pin if specified
5348b8
+        elif deployer.mdict['pki_pin']:
5348b8
+            deployer.mdict['pki_server_database_password'] = deployer.mdict['pki_pin']
5348b8
+
5348b8
+        # otherwise, generate a random password
5348b8
+        else:
5348b8
+            deployer.mdict['pki_server_database_password'] = pki.generate_password()
5348b8
+
5348b8
+        # generate random password for client database if not specified
5348b8
+        if not deployer.mdict['pki_client_database_password']:
5348b8
+            deployer.mdict['pki_client_database_password'] = pki.generate_password()
5348b8
+
5348b8
         # ALWAYS initialize 'uid' and 'gid'
5348b8
         deployer.identity.add_uid_and_gid(deployer.mdict['pki_user'],
5348b8
                                           deployer.mdict['pki_group'])
5348b8
-- 
5348b8
1.8.3.1
5348b8
5348b8
5348b8
From 4886a7f4fa3678cd26c7c38c5140784dc53b76b5 Mon Sep 17 00:00:00 2001
5348b8
From: "Endi S. Dewata" <edewata@redhat.com>
5348b8
Date: Tue, 2 Oct 2018 18:11:43 +0200
5348b8
Subject: [PATCH 11/13] Updated pki-server subsystem-cert-validate output
5348b8
5348b8
The pki-server subsystem-cert-validate CLI has been modified to
5348b8
show the actual message generated by NSS if the validation fails.
5348b8
5348b8
(cherry picked from commit eb8baf8b51e3c897caddbc16df2fd226308a0876)
5348b8
---
5348b8
 base/server/python/pki/server/cli/subsystem.py | 7 ++++---
5348b8
 1 file changed, 4 insertions(+), 3 deletions(-)
5348b8
5348b8
diff --git a/base/server/python/pki/server/cli/subsystem.py b/base/server/python/pki/server/cli/subsystem.py
5348b8
index 57093d4..068d1db 100644
5348b8
--- a/base/server/python/pki/server/cli/subsystem.py
5348b8
+++ b/base/server/python/pki/server/cli/subsystem.py
5348b8
@@ -1038,10 +1038,11 @@ class SubsystemCertValidateCLI(pki.cli.CLI):
5348b8
             return True
5348b8
 
5348b8
         except subprocess.CalledProcessError as e:
5348b8
-            if e.returncode == 1:
5348b8
-                print('  Status: INVALID')
5348b8
+            if e.output:
5348b8
+                status = e.output.decode('utf-8')
5348b8
             else:
5348b8
-                print('  Status: ERROR: %s' % e.output)
5348b8
+                status = 'ERROR'
5348b8
+            print('  Status: %s' % status)
5348b8
             return False
5348b8
 
5348b8
         finally:
5348b8
-- 
5348b8
1.8.3.1
5348b8
5348b8
5348b8
From 0115c05727962dac2bdb3865388144315719a0b0 Mon Sep 17 00:00:00 2001
5348b8
From: "Endi S. Dewata" <edewata@redhat.com>
5348b8
Date: Fri, 24 Aug 2018 03:36:15 +0200
5348b8
Subject: [PATCH 12/13] Added docs for installation with custom keys
5348b8
5348b8
https://pagure.io/dogtagpki/issue/3053
5348b8
5348b8
Change-Id: I8f8fdbb7cc1888092bd7ba686a626137113ed2d5
5348b8
(cherry picked from commit a8405a1f8bd4c3fd10213725a32da0419e622252)
5348b8
---
5348b8
 .../Installing_CA_with_Custom_CA_Signing_Key.md    | 169 ++++++++++++++++++
5348b8
 .../Installing_KRA_with_Custom_Keys.md             | 190 +++++++++++++++++++++
5348b8
 .../Installing_OCSP_with_Custom_Keys.md            | 183 ++++++++++++++++++++
5348b8
 3 files changed, 542 insertions(+)
5348b8
 create mode 100644 docs/installation/Installing_CA_with_Custom_CA_Signing_Key.md
5348b8
 create mode 100644 docs/installation/Installing_KRA_with_Custom_Keys.md
5348b8
 create mode 100644 docs/installation/Installing_OCSP_with_Custom_Keys.md
5348b8
5348b8
diff --git a/docs/installation/Installing_CA_with_Custom_CA_Signing_Key.md b/docs/installation/Installing_CA_with_Custom_CA_Signing_Key.md
5348b8
new file mode 100644
5348b8
index 0000000..5cdf786
5348b8
--- /dev/null
5348b8
+++ b/docs/installation/Installing_CA_with_Custom_CA_Signing_Key.md
5348b8
@@ -0,0 +1,169 @@
5348b8
+Installing CA with Custom CA Signing Key
5348b8
+========================================
5348b8
+
5348b8
+Overview
5348b8
+--------
5348b8
+
5348b8
+This page describes the process to install a CA subsystem with a custom CA signing key, CSR, and certificate.
5348b8
+
5348b8
+Starting CA Subsystem Installation
5348b8
+----------------------------------
5348b8
+
5348b8
+Prepare a file (e.g. ca-step1.cfg) that contains the deployment configuration step 1, for example:
5348b8
+
5348b8
+```
5348b8
+[DEFAULT]
5348b8
+pki_server_database_password=Secret.123
5348b8
+
5348b8
+[CA]
5348b8
+pki_admin_email=caadmin@example.com
5348b8
+pki_admin_name=caadmin
5348b8
+pki_admin_nickname=caadmin
5348b8
+pki_admin_password=Secret.123
5348b8
+pki_admin_uid=caadmin
5348b8
+
5348b8
+pki_client_database_password=Secret.123
5348b8
+pki_client_database_purge=False
5348b8
+pki_client_pkcs12_password=Secret.123
5348b8
+
5348b8
+pki_ds_base_dn=dc=ca,dc=pki,dc=example,dc=com
5348b8
+pki_ds_database=ca
5348b8
+pki_ds_password=Secret.123
5348b8
+
5348b8
+pki_security_domain_name=EXAMPLE
5348b8
+
5348b8
+pki_ca_signing_nickname=ca_signing
5348b8
+pki_ocsp_signing_nickname=ca_ocsp_signing
5348b8
+pki_audit_signing_nickname=ca_audit_signing
5348b8
+pki_sslserver_nickname=sslserver
5348b8
+pki_subsystem_nickname=subsystem
5348b8
+
5348b8
+pki_external=True
5348b8
+pki_external_step_two=False
5348b8
+```
5348b8
+
5348b8
+Then execute the following command:
5348b8
+
5348b8
+```
5348b8
+$ pkispawn -f ca-step1.cfg -s CA
5348b8
+```
5348b8
+
5348b8
+It will install CA subsystem in a Tomcat instance (default is pki-tomcat) and create the following NSS databases:
5348b8
+* server NSS database: /etc/pki/pki-tomcat/alias
5348b8
+* admin NSS database: ~/.dogtag/pki-tomcat/ca/alias
5348b8
+
5348b8
+Since there is no CSR path parameter specified, it will not generate the CA signing key by default.
5348b8
+
5348b8
+Generating CA Signing Key, CSR, and Certificate
5348b8
+-----------------------------------------------
5348b8
+
5348b8
+Generate a custom CA signing key in the server NSS database, then generate a CSR and store it in a file (e.g. ca_signing.csr).
5348b8
+
5348b8
+Use the CSR to issue the CA signing certificate:
5348b8
+* for root CA installation, generate a self-signed CA signing certificate
5348b8
+* for subordinate CA installation, submit the CSR to an external CA to issue the CA signing certificate
5348b8
+
5348b8
+Store the CA signing certificate in a file (e.g. ca_signing.crt). The CA signing certificate can be specified as a single certificate or a PKCS #7 certificate chain in PEM format.
5348b8
+
5348b8
+If the CA signing certificate was issued by an external CA, store the external CA certificate chain in a file (e.g. external.crt). The certificate chain can be specified as a single certificate or a PKCS #7 certificate chain in PEM format. The certificate chain should include all CA certificates from the root CA to the external CA that issued the CA signing certificate, but it should not include the CA signing certificate itself.
5348b8
+
5348b8
+See also:
5348b8
+* [Generating CA Signing Certificate](http://www.dogtagpki.org/wiki/Generating_CA_Signing_Certificate)
5348b8
+
5348b8
+Finishing CA Subsystem Installation
5348b8
+-----------------------------------
5348b8
+
5348b8
+Prepare another file (e.g. ca-step2.cfg) that contains the deployment configuration step 2. The file can be copied from step 1 (i.e. ca-step1.cfg) with additional changes below.
5348b8
+
5348b8
+Specify step 2 with the following parameter:
5348b8
+
5348b8
+```
5348b8
+pki_external_step_two=True
5348b8
+```
5348b8
+
5348b8
+Specify the custom CA signing CSR with the following parameter:
5348b8
+
5348b8
+```
5348b8
+pki_ca_signing_csr_path=ca_signing.csr
5348b8
+```
5348b8
+
5348b8
+Specify the custom CA signing certificate with the following parameter:
5348b8
+
5348b8
+```
5348b8
+pki_ca_signing_cert_path=ca_signing.crt
5348b8
+```
5348b8
+
5348b8
+If the CA signing certificate was issued by an external CA, specify the external CA certificate chain with the following parameters:
5348b8
+
5348b8
+```
5348b8
+pki_cert_chain_nickname=external
5348b8
+pki_cert_chain_path=external.crt
5348b8
+```
5348b8
+
5348b8
+Finally, execute the following command:
5348b8
+
5348b8
+```
5348b8
+$ pkispawn -f ca-step2.cfg -s CA
5348b8
+```
5348b8
+
5348b8
+Verifying System Certificates
5348b8
+-----------------------------
5348b8
+
5348b8
+Verify that the server NSS database contains the following certificates:
5348b8
+
5348b8
+```
5348b8
+$ certutil -L -d /etc/pki/pki-tomcat/alias
5348b8
+
5348b8
+Certificate Nickname                                         Trust Attributes
5348b8
+                                                             SSL,S/MIME,JAR/XPI
5348b8
+
5348b8
+external                                                     CT,C,C
5348b8
+ca_signing                                                   CTu,Cu,Cu
5348b8
+ca_ocsp_signing                                              u,u,u
5348b8
+subsystem                                                    u,u,u
5348b8
+ca_audit_signing                                             u,u,Pu
5348b8
+sslserver                                                    u,u,u
5348b8
+```
5348b8
+
5348b8
+Verifying Admin Certificate
5348b8
+---------------------------
5348b8
+
5348b8
+Prepare a client NSS database (e.g. ~/.dogtag/nssdb):
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 client-init
5348b8
+```
5348b8
+
5348b8
+Import the external CA certificate chain:
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 client-cert-import --ca-cert external.crt
5348b8
+```
5348b8
+
5348b8
+Import the CA signing certificate:
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 client-cert-import ca_signing --ca-cert ca_signing.crt
5348b8
+```
5348b8
+
5348b8
+Import admin key and certificate:
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 client-cert-import \
5348b8
+ --pkcs12 ~/.dogtag/pki-tomcat/ca_admin_cert.p12 \
5348b8
+ --pkcs12-password-file ~/.dogtag/pki-tomcat/ca/pkcs12_password.conf
5348b8
+```
5348b8
+
5348b8
+Verify that the admin certificate can be used to access the CA subsystem by executing the following command:
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 -n caadmin ca-user-show caadmin
5348b8
+--------------
5348b8
+User "caadmin"
5348b8
+--------------
5348b8
+  User ID: caadmin
5348b8
+  Full name: caadmin
5348b8
+  Email: caadmin@example.com
5348b8
+  Type: adminType
5348b8
+  State: 1
5348b8
+```
5348b8
diff --git a/docs/installation/Installing_KRA_with_Custom_Keys.md b/docs/installation/Installing_KRA_with_Custom_Keys.md
5348b8
new file mode 100644
5348b8
index 0000000..e555363
5348b8
--- /dev/null
5348b8
+++ b/docs/installation/Installing_KRA_with_Custom_Keys.md
5348b8
@@ -0,0 +1,190 @@
5348b8
+Installing KRA with Custom Keys
5348b8
+===============================
5348b8
+
5348b8
+Overview
5348b8
+--------
5348b8
+
5348b8
+This page describes the process to install a KRA subsystem with custom KRA system and admin keys, CSRs, and certificates.
5348b8
+
5348b8
+Starting KRA Subsystem Installation
5348b8
+-----------------------------------
5348b8
+
5348b8
+Prepare a file (e.g. kra-step1.cfg) that contains the deployment configuration step 1, for example:
5348b8
+
5348b8
+```
5348b8
+[DEFAULT]
5348b8
+pki_server_database_password=Secret.123
5348b8
+
5348b8
+[KRA]
5348b8
+pki_admin_email=kraadmin@example.com
5348b8
+pki_admin_name=kraadmin
5348b8
+pki_admin_nickname=kraadmin
5348b8
+pki_admin_password=Secret.123
5348b8
+pki_admin_uid=kraadmin
5348b8
+
5348b8
+pki_client_database_password=Secret.123
5348b8
+pki_client_database_purge=False
5348b8
+pki_client_pkcs12_password=Secret.123
5348b8
+
5348b8
+pki_ds_base_dn=dc=kra,dc=pki,dc=example,dc=com
5348b8
+pki_ds_database=kra
5348b8
+pki_ds_password=Secret.123
5348b8
+
5348b8
+pki_security_domain_name=EXAMPLE
5348b8
+pki_security_domain_user=caadmin
5348b8
+pki_security_domain_password=Secret.123
5348b8
+
5348b8
+pki_storage_nickname=kra_storage
5348b8
+pki_transport_nickname=kra_transport
5348b8
+pki_subsystem_nickname=subsystem
5348b8
+pki_sslserver_nickname=sslserver
5348b8
+pki_audit_signing_nickname=kra_audit_signing
5348b8
+
5348b8
+pki_external=True
5348b8
+pki_external_step_two=False
5348b8
+```
5348b8
+
5348b8
+Then execute the following command:
5348b8
+
5348b8
+```
5348b8
+$ pkispawn -f kra-step1.cfg -s KRA
5348b8
+```
5348b8
+
5348b8
+It will install KRA subsystem in a Tomcat instance (default is pki-tomcat) and create the following NSS databases:
5348b8
+* server NSS database: /etc/pki/pki-tomcat/alias
5348b8
+* admin NSS database: ~/dogtag/pki-tomcat/kra/alias
5348b8
+
5348b8
+Since there are no CSR path parameters specified, it will not generate KRA system and admin keys.
5348b8
+
5348b8
+Generating KRA Keys, CSRs, and Certificates
5348b8
+-------------------------------------------
5348b8
+
5348b8
+Generate custom KRA system keys in the server NSS database and admin key in the admin NSS database, then generate the CSRs and store them in files, for example:
5348b8
+* kra_storage.csr
5348b8
+* kra_transport.csr
5348b8
+* subsystem.csr
5348b8
+* sslserver.csr
5348b8
+* kra_audit_signing.csr
5348b8
+* kra_admin.csr
5348b8
+
5348b8
+Submit the CSRs to an external CA to issue the certificates, then store the certificates in files, for example:
5348b8
+* kra_storage.crt
5348b8
+* kra_transport.crt
5348b8
+* subsystem.crt
5348b8
+* sslserver.crt
5348b8
+* kra_audit_signing.crt
5348b8
+* kra_admin.crt
5348b8
+
5348b8
+The certificates can be specified as single certificates or PKCS #7 certificate chains in PEM format.
5348b8
+
5348b8
+Store the external CA certificate chain in a file (e.g. ca_signing.crt). The certificate chain can be specified as a single certificate or PKCS #7 certificate chain in PEM format. The certificate chain should include all CA certificates from the root CA to the external CA that issued the KRA system and admin certificates.
5348b8
+
5348b8
+See also:
5348b8
+* [Generating KRA Storage Certificate](http://www.dogtagpki.org/wiki/Generating_KRA_Storage_Certificate)
5348b8
+* [Generating KRA Transport Certificate](http://www.dogtagpki.org/wiki/Generating_KRA_Transport_Certificate)
5348b8
+* [Generating Subsystem Certificate](http://www.dogtagpki.org/wiki/Generating_Subsystem_Certificate)
5348b8
+* [Generating SSL Server Certificate](http://www.dogtagpki.org/wiki/Generating_SSL_Server_Certificate)
5348b8
+* [Generating Audit Signing Certificate](http://www.dogtagpki.org/wiki/Generating_Audit_Signing_Certificate)
5348b8
+* [Generating Admin Certificate](http://www.dogtagpki.org/wiki/Generating_Admin_Certificate)
5348b8
+
5348b8
+Finishing KRA Subsystem Installation
5348b8
+------------------------------------
5348b8
+
5348b8
+Prepare another file (e.g. kra-step2.cfg) that contains the deployment configuration step 2. The file can be copied from step 1 (i.e. kra-step1.cfg) with additional changes below.
5348b8
+
5348b8
+Specify step 2 with the following parameter:
5348b8
+
5348b8
+```
5348b8
+pki_external_step_two=True
5348b8
+```
5348b8
+
5348b8
+Specify the custom CSRs with the following parameters:
5348b8
+
5348b8
+```
5348b8
+pki_storage_csr_path=kra_storage.csr
5348b8
+pki_transport_csr_path=kra_transport.csr
5348b8
+pki_subsystem_csr_path=subsystem.csr
5348b8
+pki_sslserver_csr_path=sslserver.csr
5348b8
+pki_audit_signing_csr_path=kra_audit_signing.csr
5348b8
+pki_admin_csr_path=kra_admin.csr
5348b8
+```
5348b8
+
5348b8
+Specify the custom certificates with the following parameters:
5348b8
+
5348b8
+```
5348b8
+pki_storage_cert_path=kra_storage.crt
5348b8
+pki_transport_cert_path=kra_transport.crt
5348b8
+pki_subsystem_cert_path=subsystem.crt
5348b8
+pki_sslserver_cert_path=sslserver.crt
5348b8
+pki_audit_signing_cert_path=kra_audit_signing.crt
5348b8
+pki_admin_cert_path=kra_admin.crt
5348b8
+```
5348b8
+
5348b8
+Specify the external CA certificate chain with the following parameters:
5348b8
+
5348b8
+```
5348b8
+pki_cert_chain_nickname=ca_signing
5348b8
+pki_cert_chain_path=ca_signing.crt
5348b8
+```
5348b8
+
5348b8
+Finally, execute the following command:
5348b8
+
5348b8
+```
5348b8
+$ pkispawn -f kra-step2.cfg -s KRA
5348b8
+```
5348b8
+
5348b8
+Verifying System Certificates
5348b8
+-----------------------------
5348b8
+
5348b8
+Verify that the server NSS database contains the following certificates:
5348b8
+
5348b8
+```
5348b8
+$ certutil -L -d /etc/pki/pki-tomcat/alias
5348b8
+
5348b8
+Certificate Nickname                                         Trust Attributes
5348b8
+                                                             SSL,S/MIME,JAR/XPI
5348b8
+
5348b8
+ca_signing                                                   CT,C,C
5348b8
+kra_storage                                                  CTu,Cu,Cu
5348b8
+kra_transport                                                u,u,u
5348b8
+subsystem                                                    u,u,u
5348b8
+kra_audit_signing                                            u,u,Pu
5348b8
+sslserver                                                    u,u,u
5348b8
+```
5348b8
+
5348b8
+Verifying Admin Certificate
5348b8
+---------------------------
5348b8
+
5348b8
+Prepare a client NSS database (e.g. ~/.dogtag/nssdb):
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 client-init
5348b8
+```
5348b8
+
5348b8
+Import the external CA certificate chain:
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 client-cert-import --ca-cert ca_signing.crt
5348b8
+```
5348b8
+
5348b8
+Import the admin key and certificate:
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 client-cert-import \
5348b8
+ --pkcs12 ~/.dogtag/pki-tomcat/kra_admin_cert.p12 \
5348b8
+ --pkcs12-password-file ~/.dogtag/pki-tomcat/ca/pkcs12_password.conf
5348b8
+```
5348b8
+
5348b8
+Verify that the admin certificate can be used to access KRA by executing the following command:
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 -n kraadmin kra-user-show kraadmin
5348b8
+---------------
5348b8
+User "kraadmin"
5348b8
+---------------
5348b8
+  User ID: kraadmin
5348b8
+  Full name: kraadmin
5348b8
+  Email: kraadmin@example.com
5348b8
+  Type: adminType
5348b8
+  State: 1
5348b8
+```
5348b8
diff --git a/docs/installation/Installing_OCSP_with_Custom_Keys.md b/docs/installation/Installing_OCSP_with_Custom_Keys.md
5348b8
new file mode 100644
5348b8
index 0000000..dca4f79
5348b8
--- /dev/null
5348b8
+++ b/docs/installation/Installing_OCSP_with_Custom_Keys.md
5348b8
@@ -0,0 +1,183 @@
5348b8
+Installing OCSP with Custom Keys
5348b8
+================================
5348b8
+
5348b8
+Overview
5348b8
+--------
5348b8
+
5348b8
+This page describes the process to install a OCSP subsystem with custom OCSP system and admin keys, CSRs, and certificates.
5348b8
+
5348b8
+Starting OCSP Subsystem Installation
5348b8
+------------------------------------
5348b8
+
5348b8
+Prepare a file (e.g. ocsp-step1.cfg) that contains the deployment configuration step 1, for example:
5348b8
+
5348b8
+```
5348b8
+[DEFAULT]
5348b8
+pki_server_database_password=Secret.123
5348b8
+
5348b8
+[OCSP]
5348b8
+pki_admin_email=ocspadmin@example.com
5348b8
+pki_admin_name=ocspadmin
5348b8
+pki_admin_nickname=ocspadmin
5348b8
+pki_admin_password=Secret.123
5348b8
+pki_admin_uid=ocspadmin
5348b8
+
5348b8
+pki_client_database_password=Secret.123
5348b8
+pki_client_database_purge=False
5348b8
+pki_client_pkcs12_password=Secret.123
5348b8
+
5348b8
+pki_ds_base_dn=dc=ocsp,dc=pki,dc=example,dc=com
5348b8
+pki_ds_database=ocsp
5348b8
+pki_ds_password=Secret.123
5348b8
+
5348b8
+pki_security_domain_name=EXAMPLE
5348b8
+pki_security_domain_user=caadmin
5348b8
+pki_security_domain_password=Secret.123
5348b8
+
5348b8
+pki_ocsp_signing_nickname=ocsp_signing
5348b8
+pki_subsystem_nickname=subsystem
5348b8
+pki_sslserver_nickname=sslserver
5348b8
+pki_audit_signing_nickname=ocsp_audit_signing
5348b8
+
5348b8
+pki_external=True
5348b8
+pki_external_step_two=False
5348b8
+```
5348b8
+
5348b8
+Then execute the following command:
5348b8
+
5348b8
+```
5348b8
+$ pkispawn -f ocsp-step1.cfg -s OCSP
5348b8
+```
5348b8
+
5348b8
+It will install OCSP subsystem in a Tomcat instance (default is pki-tomcat) and create the following NSS databases:
5348b8
+* server NSS database: /etc/pki/pki-tomcat/alias
5348b8
+* admin NSS database: ~/.dogtag/pki-tomcat/ocsp/alias
5348b8
+
5348b8
+Since there are no CSR path parameters specified, it will not generate the OCSP system and admin keys.
5348b8
+
5348b8
+Generating OCSP Keys, CSRs, and Certificates
5348b8
+--------------------------------------------
5348b8
+
5348b8
+Generate custom OCSP system keys in the server NSS database and admin key in the admin NSS database, then generate the CSRs and store them in files, for example:
5348b8
+* ocsp_signing.csr
5348b8
+* subsystem.csr
5348b8
+* sslserver.csr
5348b8
+* ocsp_audit_signing.csr
5348b8
+* ocsp_admin.csr
5348b8
+
5348b8
+Submit the CSRs to an external CA to issue the certificates, then store the certificates in files, for example:
5348b8
+* ocsp_signing.crt
5348b8
+* subsystem.crt
5348b8
+* sslserver.crt
5348b8
+* ocsp_audit_signing.crt
5348b8
+* ocsp_admin.crt
5348b8
+
5348b8
+The certificates can be specified as single certificates or PKCS #7 certificate chains in PEM format.
5348b8
+
5348b8
+Store the external CA certificate chain in a file (e.g. ca_signing.crt). The certificate chain can be specified as a single certificate or PKCS #7 certificate chain in PEM format. The certificate chain should include all CA certificates from the root CA to the external CA that issued the OCSP system and admin certificates.
5348b8
+
5348b8
+See also:
5348b8
+* [Generating OCSP Signing Certificate](http://www.dogtagpki.org/wiki/Generating_OCSP_Signing_Certificate)
5348b8
+* [Generating Subsystem Certificate](http://www.dogtagpki.org/wiki/Generating_Subsystem_Certificate)
5348b8
+* [Generating SSL Server Certificate](http://www.dogtagpki.org/wiki/Generating_SSL_Server_Certificate)
5348b8
+* [Generating Audit Signing Certificate](http://www.dogtagpki.org/wiki/Generating_Audit_Signing_Certificate)
5348b8
+* [Generating Admin Certificate](http://www.dogtagpki.org/wiki/Generating_Admin_Certificate)
5348b8
+
5348b8
+Finishing OCSP Subsystem Installation
5348b8
+-------------------------------------
5348b8
+
5348b8
+Prepare another file (e.g. ocsp-step2.cfg) that contains the deployment configuration step 2. The file can be copied from step 1 (i.e. ocsp-step1.cfg) with additional changes below.
5348b8
+
5348b8
+Specify step 2 with the following parameter:
5348b8
+
5348b8
+```
5348b8
+pki_external_step_two=True
5348b8
+```
5348b8
+
5348b8
+Specify the custom CSRs with the following parameters:
5348b8
+
5348b8
+```
5348b8
+pki_ocsp_signing_csr_path=ocsp_signing.csr
5348b8
+pki_subsystem_csr_path=subsystem.csr
5348b8
+pki_sslserver_csr_path=sslserver.csr
5348b8
+pki_audit_signing_csr_path=ocsp_audit_signing.csr
5348b8
+pki_admin_csr_path=ocsp_admin.csr
5348b8
+```
5348b8
+
5348b8
+Specify the custom certificates with the following parameters:
5348b8
+
5348b8
+```
5348b8
+pki_ocsp_signing_cert_path=ocsp_signing.crt
5348b8
+pki_subsystem_cert_path=subsystem.crt
5348b8
+pki_sslserver_cert_path=sslserver.crt
5348b8
+pki_audit_signing_cert_path=ocsp_audit_signing.crt
5348b8
+pki_admin_cert_path=ocsp_admin.crt
5348b8
+```
5348b8
+
5348b8
+Specify the external CA certificate chain with the following parameters:
5348b8
+
5348b8
+```
5348b8
+pki_cert_chain_nickname=ca_signing
5348b8
+pki_cert_chain_path=ca_signing.crt
5348b8
+```
5348b8
+
5348b8
+Finally, execute the following command:
5348b8
+
5348b8
+```
5348b8
+$ pkispawn -f ocsp-step2.cfg -s OCSP
5348b8
+```
5348b8
+
5348b8
+Verifying System Certificates
5348b8
+-----------------------------
5348b8
+
5348b8
+Verify that the server NSS database contains the following certificates:
5348b8
+
5348b8
+```
5348b8
+$ certutil -L -d /etc/pki/pki-tomcat/alias
5348b8
+
5348b8
+Certificate Nickname                                         Trust Attributes
5348b8
+                                                             SSL,S/MIME,JAR/XPI
5348b8
+
5348b8
+ca_signing                                                   CT,C,C
5348b8
+ocsp_signing                                                 CTu,Cu,Cu
5348b8
+subsystem                                                    u,u,u
5348b8
+ocsp_audit_signing                                           u,u,Pu
5348b8
+sslserver                                                    u,u,u
5348b8
+```
5348b8
+
5348b8
+Verifying Admin Certificate
5348b8
+---------------------------
5348b8
+
5348b8
+Prepare a client NSS database (e.g. ~/.dogtag/nssdb):
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 client-init
5348b8
+```
5348b8
+
5348b8
+Import the external CA certificate chain:
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 client-cert-import --ca-cert ca_signing.crt
5348b8
+```
5348b8
+
5348b8
+Import the admin key and certificate:
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 client-cert-import \
5348b8
+ --pkcs12 ~/.dogtag/pki-tomcat/ocsp_admin_cert.p12 \
5348b8
+ --pkcs12-password-file ~/.dogtag/pki-tomcat/ca/pkcs12_password.conf
5348b8
+```
5348b8
+
5348b8
+Verify that the admin certificate can be used to access the OCSP subsystem by executing the following command:
5348b8
+
5348b8
+```
5348b8
+$ pki -c Secret.123 -n ocspadmin ocsp-user-show ocspadmin
5348b8
+----------------
5348b8
+User "ocspadmin"
5348b8
+----------------
5348b8
+  User ID: ocspadmin
5348b8
+  Full name: ocspadmin
5348b8
+  Email: ocspadmin@example.com
5348b8
+  Type: adminType
5348b8
+  State: 1
5348b8
+```
5348b8
-- 
5348b8
1.8.3.1
5348b8
5348b8
5348b8
From 253f16813de60b1951b769a437c92322e36647bf Mon Sep 17 00:00:00 2001
5348b8
From: Christina Fu <cfu@redhat.com>
5348b8
Date: Fri, 9 Nov 2018 11:06:57 -0800
5348b8
Subject: [PATCH 13/13] bug 1653863 tools supporting CMC requests output keyID
5348b8
 needs to be captured in file
5348b8
5348b8
This patch adds code in both CRMFPopClient and PKCS10Client to automatically
5348b8
write the private key id into a file named <output>.keyId so that
5348b8
they can be featched later for CMCRequest
5348b8
<output>is the name of the file specified with the "-o" option.
5348b8
5348b8
This patch also changed all references from "CMC self-test" to
5348b8
"CMC shared secret" instead.
5348b8
5348b8
A test feature is also added to CMCRequest.
5348b8
5348b8
fixes https://bugzilla.redhat.com/show_bug.cgi?id=1655951
5348b8
5348b8
Change-Id: Iaf2772be54f9937da456655cdec688f13f6e8b71
5348b8
(cherry picked from commit cb99e112b9421f6fe98b4ac5ab5885c28ee958c3)
5348b8
---
5348b8
 base/ca/shared/conf/CS.cfg                         |  10 +-
5348b8
 base/ca/shared/conf/registry.cfg                   |   8 +-
5348b8
 .../profiles/ca/caECFullCMCSelfSignedCert.cfg      |  82 --------
5348b8
 .../profiles/ca/caECFullCMCSharedTokenCert.cfg     |  82 ++++++++
5348b8
 .../shared/profiles/ca/caFullCMCSelfSignedCert.cfg |  82 --------
5348b8
 .../profiles/ca/caFullCMCSharedTokenCert.cfg       |  82 ++++++++
5348b8
 base/java-tools/man/man1/CMCRequest.1              |  22 +-
5348b8
 base/java-tools/man/man1/PKCS10Client.1            |   3 +-
5348b8
 .../src/com/netscape/cmstools/CMCRequest.java      | 227 ++++++++++++++++-----
5348b8
 .../src/com/netscape/cmstools/CRMFPopClient.java   |  22 +-
5348b8
 .../src/com/netscape/cmstools/PKCS10Client.java    |  24 ++-
5348b8
 .../CMCSelfSignedSubjectNameConstraint.java        | 129 ------------
5348b8
 .../CMCSharedTokenSubjectNameConstraint.java       | 130 ++++++++++++
5348b8
 13 files changed, 526 insertions(+), 377 deletions(-)
5348b8
 delete mode 100644 base/ca/shared/profiles/ca/caECFullCMCSelfSignedCert.cfg
5348b8
 create mode 100644 base/ca/shared/profiles/ca/caECFullCMCSharedTokenCert.cfg
5348b8
 delete mode 100644 base/ca/shared/profiles/ca/caFullCMCSelfSignedCert.cfg
5348b8
 create mode 100644 base/ca/shared/profiles/ca/caFullCMCSharedTokenCert.cfg
5348b8
 delete mode 100644 base/server/cms/src/com/netscape/cms/profile/constraint/CMCSelfSignedSubjectNameConstraint.java
5348b8
 create mode 100644 base/server/cms/src/com/netscape/cms/profile/constraint/CMCSharedTokenSubjectNameConstraint.java
5348b8
5348b8
diff --git a/base/ca/shared/conf/CS.cfg b/base/ca/shared/conf/CS.cfg
5348b8
index 4cef240..29d4fd4 100644
5348b8
--- a/base/ca/shared/conf/CS.cfg
5348b8
+++ b/base/ca/shared/conf/CS.cfg
5348b8
@@ -975,7 +975,7 @@ oidmap.pse.oid=2.16.840.1.113730.1.18
5348b8
 oidmap.subject_info_access.class=netscape.security.extensions.SubjectInfoAccessExtension
5348b8
 oidmap.subject_info_access.oid=1.3.6.1.5.5.7.1.11
5348b8
 os.userid=nobody
5348b8
-profile.list=caCMCserverCert,caCMCECserverCert,caCMCECsubsystemCert,caCMCsubsystemCert,caCMCauditSigningCert,caCMCcaCert,caCMCocspCert,caCMCkraTransportCert,caCMCkraStorageCert,caUserCert,caECUserCert,caUserSMIMEcapCert,caDualCert,caDirBasedDualCert,AdminCert,ECAdminCert,caSignedLogCert,caTPSCert,caRARouterCert,caRouterCert,caServerCert,caECServerCert,caSubsystemCert,caECSubsystemCert,caOtherCert,caCACert,caCMCcaCert,caCrossSignedCACert,caInstallCACert,caRACert,caOCSPCert,caStorageCert,caTransportCert,caDirPinUserCert,caECDirPinUserCert,caDirUserCert,caECDirUserCert,caAgentServerCert,caECAgentServerCert,caAgentFileSigning,caCMCUserCert,caCMCECUserCert,caFullCMCUserCert,caECFullCMCUserCert,caFullCMCUserSignedCert,caECFullCMCUserSignedCert,caFullCMCSelfSignedCert,caECFullCMCSelfSignedCert,caSimpleCMCUserCert,caECSimpleCMCUserCert,caTokenDeviceKeyEnrollment,caTokenUserEncryptionKeyEnrollment,caTokenUserSigningKeyEnrollment,caTempTokenDeviceKeyEnrollment,caTempTokenUserEncryptionKeyEnrollment,caTempTokenUserSigningKeyEnrollment,caAdminCert,caECAdminCert,caInternalAuthServerCert,caECInternalAuthServerCert,caInternalAuthTransportCert,caInternalAuthDRMstorageCert,caInternalAuthSubsystemCert,caECInternalAuthSubsystemCert,caInternalAuthOCSPCert,caInternalAuthAuditSigningCert,DomainController,caDualRAuserCert,caRAagentCert,caRAserverCert,caUUIDdeviceCert,caSSLClientSelfRenewal,caDirUserRenewal,caManualRenewal,caTokenMSLoginEnrollment,caTokenUserSigningKeyRenewal,caTokenUserEncryptionKeyRenewal,caTokenUserAuthKeyRenewal,caJarSigningCert,caIPAserviceCert,caEncUserCert,caSigningUserCert,caTokenUserDelegateAuthKeyEnrollment,caTokenUserDelegateSigningKeyEnrollment
5348b8
+profile.list=caCMCserverCert,caCMCECserverCert,caCMCECsubsystemCert,caCMCsubsystemCert,caCMCauditSigningCert,caCMCcaCert,caCMCocspCert,caCMCkraTransportCert,caCMCkraStorageCert,caUserCert,caECUserCert,caUserSMIMEcapCert,caDualCert,caDirBasedDualCert,AdminCert,ECAdminCert,caSignedLogCert,caTPSCert,caRARouterCert,caRouterCert,caServerCert,caECServerCert,caSubsystemCert,caECSubsystemCert,caOtherCert,caCACert,caCMCcaCert,caCrossSignedCACert,caInstallCACert,caRACert,caOCSPCert,caStorageCert,caTransportCert,caDirPinUserCert,caECDirPinUserCert,caDirUserCert,caECDirUserCert,caAgentServerCert,caECAgentServerCert,caAgentFileSigning,caCMCUserCert,caCMCECUserCert,caFullCMCUserCert,caECFullCMCUserCert,caFullCMCUserSignedCert,caECFullCMCUserSignedCert,caFullCMCSharedTokenCert,caECFullCMCSharedTokenCert,caSimpleCMCUserCert,caECSimpleCMCUserCert,caTokenDeviceKeyEnrollment,caTokenUserEncryptionKeyEnrollment,caTokenUserSigningKeyEnrollment,caTempTokenDeviceKeyEnrollment,caTempTokenUserEncryptionKeyEnrollment,caTempTokenUserSigningKeyEnrollment,caAdminCert,caECAdminCert,caInternalAuthServerCert,caECInternalAuthServerCert,caInternalAuthTransportCert,caInternalAuthDRMstorageCert,caInternalAuthSubsystemCert,caECInternalAuthSubsystemCert,caInternalAuthOCSPCert,caInternalAuthAuditSigningCert,DomainController,caDualRAuserCert,caRAagentCert,caRAserverCert,caUUIDdeviceCert,caSSLClientSelfRenewal,caDirUserRenewal,caManualRenewal,caTokenMSLoginEnrollment,caTokenUserSigningKeyRenewal,caTokenUserEncryptionKeyRenewal,caTokenUserAuthKeyRenewal,caJarSigningCert,caIPAserviceCert,caEncUserCert,caSigningUserCert,caTokenUserDelegateAuthKeyEnrollment,caTokenUserDelegateSigningKeyEnrollment
5348b8
 profile.caUUIDdeviceCert.class_id=caEnrollImpl
5348b8
 profile.caUUIDdeviceCert.config=[PKI_INSTANCE_PATH]/[PKI_SUBSYSTEM_TYPE]/profiles/ca/caUUIDdeviceCert.cfg
5348b8
 profile.caManualRenewal.class_id=caEnrollImpl
5348b8
@@ -1050,10 +1050,10 @@ profile.caFullCMCUserSignedCert.class_id=caEnrollImpl
5348b8
 profile.caFullCMCUserSignedCert.config=[PKI_INSTANCE_PATH]/[PKI_SUBSYSTEM_TYPE]/profiles/ca/caFullCMCUserSignedCert.cfg
5348b8
 profile.caECFullCMCUserSignedCert.class_id=caEnrollImpl
5348b8
 profile.caECFullCMCUserSignedCert.config=[PKI_INSTANCE_PATH]/[PKI_SUBSYSTEM_TYPE]/profiles/ca/caECFullCMCUserSignedCert.cfg
5348b8
-profile.caFullCMCSelfSignedCert.class_id=caEnrollImpl
5348b8
-profile.caFullCMCSelfSignedCert.config=[PKI_INSTANCE_PATH]/[PKI_SUBSYSTEM_TYPE]/profiles/ca/caFullCMCSelfSignedCert.cfg
5348b8
-profile.caECFullCMCSelfSignedCert.class_id=caEnrollImpl
5348b8
-profile.caECFullCMCSelfSignedCert.config=[PKI_INSTANCE_PATH]/[PKI_SUBSYSTEM_TYPE]/profiles/ca/caECFullCMCSelfSignedCert.cfg
5348b8
+profile.caFullCMCSharedTokenCert.class_id=caEnrollImpl
5348b8
+profile.caFullCMCSharedTokenCert.config=[PKI_INSTANCE_PATH]/[PKI_SUBSYSTEM_TYPE]/profiles/ca/caFullCMCSharedTokenCert.cfg
5348b8
+profile.caECFullCMCSharedTokenCert.class_id=caEnrollImpl
5348b8
+profile.caECFullCMCSharedTokenCert.config=[PKI_INSTANCE_PATH]/[PKI_SUBSYSTEM_TYPE]/profiles/ca/caECFullCMCSharedTokenCert.cfg
5348b8
 profile.caInternalAuthOCSPCert.class_id=caEnrollImpl
5348b8
 profile.caInternalAuthOCSPCert.config=[PKI_INSTANCE_PATH]/[PKI_SUBSYSTEM_TYPE]/profiles/ca/caInternalAuthOCSPCert.cfg
5348b8
 profile.caInternalAuthAuditSigningCert.class_id=caEnrollImpl
5348b8
diff --git a/base/ca/shared/conf/registry.cfg b/base/ca/shared/conf/registry.cfg
5348b8
index 4fe6e93..a78af86 100644
5348b8
--- a/base/ca/shared/conf/registry.cfg
5348b8
+++ b/base/ca/shared/conf/registry.cfg
5348b8
@@ -1,5 +1,5 @@
5348b8
 types=profile,defaultPolicy,constraintPolicy,profileInput,profileOutput,profileUpdater
5348b8
-constraintPolicy.ids=noConstraintImpl,subjectNameConstraintImpl,uniqueSubjectNameConstraintImpl,userSubjectNameConstraintImpl,cmcSelfSignedSubjectNameConstraintImpl,cmcUserSignedSubjectNameConstraintImpl,caValidityConstraintImpl,validityConstraintImpl,keyUsageExtConstraintImpl,nsCertTypeExtConstraintImpl,extendedKeyUsageExtConstraintImpl,keyConstraintImpl,basicConstraintsExtConstraintImpl,extensionConstraintImpl,signingAlgConstraintImpl,uniqueKeyConstraintImpl,renewGracePeriodConstraintImpl,authzRealmConstraintImpl,externalProcessConstraintImpl
5348b8
+constraintPolicy.ids=noConstraintImpl,subjectNameConstraintImpl,uniqueSubjectNameConstraintImpl,userSubjectNameConstraintImpl,cmcSharedTokenSubjectNameConstraintImpl,cmcUserSignedSubjectNameConstraintImpl,caValidityConstraintImpl,validityConstraintImpl,keyUsageExtConstraintImpl,nsCertTypeExtConstraintImpl,extendedKeyUsageExtConstraintImpl,keyConstraintImpl,basicConstraintsExtConstraintImpl,extensionConstraintImpl,signingAlgConstraintImpl,uniqueKeyConstraintImpl,renewGracePeriodConstraintImpl,authzRealmConstraintImpl,externalProcessConstraintImpl
5348b8
 constraintPolicy.signingAlgConstraintImpl.class=com.netscape.cms.profile.constraint.SigningAlgConstraint
5348b8
 constraintPolicy.signingAlgConstraintImpl.desc=Signing Algorithm Constraint
5348b8
 constraintPolicy.signingAlgConstraintImpl.name=Signing Algorithm Constraint
5348b8
@@ -36,9 +36,9 @@ constraintPolicy.uniqueSubjectNameConstraintImpl.name=Unique Subject Name Constr
5348b8
 constraintPolicy.userSubjectNameConstraintImpl.class=com.netscape.cms.profile.constraint.UserSubjectNameConstraint
5348b8
 constraintPolicy.userSubjectNameConstraintImpl.desc=User Subject Name Constraint
5348b8
 constraintPolicy.userSubjectNameConstraintImpl.name=User Subject Name Constraint
5348b8
-constraintPolicy.cmcSelfSignedSubjectNameConstraintImpl.class=com.netscape.cms.profile.constraint.CMCSelfSignedSubjectNameConstraint
5348b8
-constraintPolicy.cmcSelfSignedSubjectNameConstraintImpl.desc=CMC Self-Signed request User Subject Name Constraint
5348b8
-constraintPolicy.cmcSelfSignedSubjectNameConstraintImpl.name=CMC Self-Signed request User Subject Name Constraint
5348b8
+constraintPolicy.cmcSharedTokenSubjectNameConstraintImpl.class=com.netscape.cms.profile.constraint.CMCSharedTokenSubjectNameConstraint
5348b8
+constraintPolicy.cmcSharedTokenSubjectNameConstraintImpl.desc=CMC Shared Token request User Subject Name Constraint
5348b8
+constraintPolicy.cmcSharedTokenSubjectNameConstraintImpl.name=CMC Shared Token request User Subject Name Constraint
5348b8
 constraintPolicy.cmcUserSignedSubjectNameConstraintImpl.class=com.netscape.cms.profile.constraint.CMCUserSignedSubjectNameConstraint
5348b8
 constraintPolicy.cmcUserSignedSubjectNameConstraintImpl.desc=CMC User-Signed request User Subject Name Constraint
5348b8
 constraintPolicy.cmcUserSignedSubjectNameConstraintImpl.name=CMC User-Signed request User Subject Name Constraint
5348b8
diff --git a/base/ca/shared/profiles/ca/caECFullCMCSelfSignedCert.cfg b/base/ca/shared/profiles/ca/caECFullCMCSelfSignedCert.cfg
5348b8
deleted file mode 100644
5348b8
index b3cc471..0000000
5348b8
--- a/base/ca/shared/profiles/ca/caECFullCMCSelfSignedCert.cfg
5348b8
+++ /dev/null
5348b8
@@ -1,82 +0,0 @@
5348b8
-desc=This certificate profile is for enrolling user certificates with ECC keys by using the self-signed CMC certificate request
5348b8
-enable=false
5348b8
-enableBy=admin
5348b8
-name=Self-Signed CMC User Certificate Enrollment
5348b8
-visible=false
5348b8
-auth.instance_id=CMCUserSignedAuth
5348b8
-input.list=i1
5348b8
-input.i1.class_id=cmcCertReqInputImpl
5348b8
-output.list=o1
5348b8
-output.o1.class_id=certOutputImpl
5348b8
-policyset.list=cmcUserCertSet
5348b8
-policyset.cmcUserCertSet.list=1,2,3,4,5,6,7,8
5348b8
-policyset.cmcUserCertSet.1.constraint.class_id=cmcSelfSignedSubjectNameConstraintImpl
5348b8
-policyset.cmcUserCertSet.1.constraint.name=CMC User-Signed Subject Name Constraint
5348b8
-policyset.cmcUserCertSet.1.default.class_id=authTokenSubjectNameDefaultImpl
5348b8
-policyset.cmcUserCertSet.1.default.name=Subject Name Default
5348b8
-policyset.cmcUserCertSet.1.default.params.name=
5348b8
-policyset.cmcUserCertSet.2.constraint.class_id=validityConstraintImpl
5348b8
-policyset.cmcUserCertSet.2.constraint.name=Validity Constraint
5348b8
-policyset.cmcUserCertSet.2.constraint.params.notAfterCheck=false
5348b8
-policyset.cmcUserCertSet.2.constraint.params.notBeforeCheck=false
5348b8
-policyset.cmcUserCertSet.2.constraint.params.range=365
5348b8
-policyset.cmcUserCertSet.2.default.class_id=validityDefaultImpl
5348b8
-policyset.cmcUserCertSet.2.default.name=Validity Default
5348b8
-policyset.cmcUserCertSet.2.default.params.range=180
5348b8
-policyset.cmcUserCertSet.2.default.params.startTime=0
5348b8
-policyset.cmcUserCertSet.3.constraint.class_id=keyConstraintImpl
5348b8
-policyset.cmcUserCertSet.3.constraint.name=Key Constraint
5348b8
-policyset.cmcUserCertSet.3.constraint.params.keyParameters=nistp256,nistp521
5348b8
-policyset.cmcUserCertSet.3.constraint.params.keyType=EC
5348b8
-policyset.cmcUserCertSet.3.default.class_id=userKeyDefaultImpl
5348b8
-policyset.cmcUserCertSet.3.default.name=Key Default
5348b8
-policyset.cmcUserCertSet.4.constraint.class_id=noConstraintImpl
5348b8
-policyset.cmcUserCertSet.4.constraint.name=No Constraint
5348b8
-policyset.cmcUserCertSet.4.default.class_id=authorityKeyIdentifierExtDefaultImpl
5348b8
-policyset.cmcUserCertSet.4.default.name=Authority Key Identifier Default
5348b8
-policyset.cmcUserCertSet.5.constraint.class_id=noConstraintImpl
5348b8
-policyset.cmcUserCertSet.5.constraint.name=No Constraint
5348b8
-policyset.cmcUserCertSet.5.default.class_id=authInfoAccessExtDefaultImpl
5348b8
-policyset.cmcUserCertSet.5.default.name=AIA Extension Default
5348b8
-policyset.cmcUserCertSet.5.default.params.authInfoAccessADEnable_0=true
5348b8
-policyset.cmcUserCertSet.5.default.params.authInfoAccessADLocationType_0=URIName
5348b8
-policyset.cmcUserCertSet.5.default.params.authInfoAccessADLocation_0=
5348b8
-policyset.cmcUserCertSet.5.default.params.authInfoAccessADMethod_0=1.3.6.1.5.5.7.48.1
5348b8
-policyset.cmcUserCertSet.5.default.params.authInfoAccessCritical=false
5348b8
-policyset.cmcUserCertSet.5.default.params.authInfoAccessNumADs=1
5348b8
-policyset.cmcUserCertSet.6.constraint.class_id=keyUsageExtConstraintImpl
5348b8
-policyset.cmcUserCertSet.6.constraint.name=Key Usage Extension Constraint
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageCritical=true
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageCrlSign=false
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageDataEncipherment=false
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageDecipherOnly=false
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageDigitalSignature=true
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageEncipherOnly=false
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageKeyAgreement=true
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageKeyCertSign=false
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageKeyEncipherment=false
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageNonRepudiation=true
5348b8
-policyset.cmcUserCertSet.6.default.class_id=keyUsageExtDefaultImpl
5348b8
-policyset.cmcUserCertSet.6.default.name=Key Usage Default
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageCritical=true
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageCrlSign=false
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageDataEncipherment=false
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageDecipherOnly=false
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageDigitalSignature=true
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageEncipherOnly=false
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageKeyAgreement=true
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageKeyCertSign=false
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageKeyEncipherment=false
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageNonRepudiation=true
5348b8
-policyset.cmcUserCertSet.7.constraint.class_id=noConstraintImpl
5348b8
-policyset.cmcUserCertSet.7.constraint.name=No Constraint
5348b8
-policyset.cmcUserCertSet.7.default.class_id=extendedKeyUsageExtDefaultImpl
5348b8
-policyset.cmcUserCertSet.7.default.name=Extended Key Usage Extension Default
5348b8
-policyset.cmcUserCertSet.7.default.params.exKeyUsageCritical=false
5348b8
-policyset.cmcUserCertSet.7.default.params.exKeyUsageOIDs=1.3.6.1.5.5.7.3.2,1.3.6.1.5.5.7.3.4
5348b8
-policyset.cmcUserCertSet.8.constraint.class_id=signingAlgConstraintImpl
5348b8
-policyset.cmcUserCertSet.8.constraint.name=No Constraint
5348b8
-policyset.cmcUserCertSet.8.constraint.params.signingAlgsAllowed=SHA256withRSA,SHA512withRSA,SHA256withEC,SHA384withRSA,SHA384withEC,SHA512withEC
5348b8
-policyset.cmcUserCertSet.8.default.class_id=signingAlgDefaultImpl
5348b8
-policyset.cmcUserCertSet.8.default.name=Signing Alg
5348b8
-policyset.cmcUserCertSet.8.default.params.signingAlg=-
5348b8
diff --git a/base/ca/shared/profiles/ca/caECFullCMCSharedTokenCert.cfg b/base/ca/shared/profiles/ca/caECFullCMCSharedTokenCert.cfg
5348b8
new file mode 100644
5348b8
index 0000000..ffdccb1
5348b8
--- /dev/null
5348b8
+++ b/base/ca/shared/profiles/ca/caECFullCMCSharedTokenCert.cfg
5348b8
@@ -0,0 +1,82 @@
5348b8
+desc=This certificate profile is for enrolling user certificates with ECC keys by using the CMC Shared Token certificate request
5348b8
+enable=false
5348b8
+enableBy=admin
5348b8
+name=CMC Shared Token User Certificate Enrollment
5348b8
+visible=false
5348b8
+auth.instance_id=CMCUserSignedAuth
5348b8
+input.list=i1
5348b8
+input.i1.class_id=cmcCertReqInputImpl
5348b8
+output.list=o1
5348b8
+output.o1.class_id=certOutputImpl
5348b8
+policyset.list=cmcUserCertSet
5348b8
+policyset.cmcUserCertSet.list=1,2,3,4,5,6,7,8
5348b8
+policyset.cmcUserCertSet.1.constraint.class_id=cmcSharedTokenSubjectNameConstraintImpl
5348b8
+policyset.cmcUserCertSet.1.constraint.name=CMC Shared Token Subject Name Constraint
5348b8
+policyset.cmcUserCertSet.1.default.class_id=authTokenSubjectNameDefaultImpl
5348b8
+policyset.cmcUserCertSet.1.default.name=Subject Name Default
5348b8
+policyset.cmcUserCertSet.1.default.params.name=
5348b8
+policyset.cmcUserCertSet.2.constraint.class_id=validityConstraintImpl
5348b8
+policyset.cmcUserCertSet.2.constraint.name=Validity Constraint
5348b8
+policyset.cmcUserCertSet.2.constraint.params.notAfterCheck=false
5348b8
+policyset.cmcUserCertSet.2.constraint.params.notBeforeCheck=false
5348b8
+policyset.cmcUserCertSet.2.constraint.params.range=365
5348b8
+policyset.cmcUserCertSet.2.default.class_id=validityDefaultImpl
5348b8
+policyset.cmcUserCertSet.2.default.name=Validity Default
5348b8
+policyset.cmcUserCertSet.2.default.params.range=180
5348b8
+policyset.cmcUserCertSet.2.default.params.startTime=0
5348b8
+policyset.cmcUserCertSet.3.constraint.class_id=keyConstraintImpl
5348b8
+policyset.cmcUserCertSet.3.constraint.name=Key Constraint
5348b8
+policyset.cmcUserCertSet.3.constraint.params.keyParameters=nistp256,nistp521
5348b8
+policyset.cmcUserCertSet.3.constraint.params.keyType=EC
5348b8
+policyset.cmcUserCertSet.3.default.class_id=userKeyDefaultImpl
5348b8
+policyset.cmcUserCertSet.3.default.name=Key Default
5348b8
+policyset.cmcUserCertSet.4.constraint.class_id=noConstraintImpl
5348b8
+policyset.cmcUserCertSet.4.constraint.name=No Constraint
5348b8
+policyset.cmcUserCertSet.4.default.class_id=authorityKeyIdentifierExtDefaultImpl
5348b8
+policyset.cmcUserCertSet.4.default.name=Authority Key Identifier Default
5348b8
+policyset.cmcUserCertSet.5.constraint.class_id=noConstraintImpl
5348b8
+policyset.cmcUserCertSet.5.constraint.name=No Constraint
5348b8
+policyset.cmcUserCertSet.5.default.class_id=authInfoAccessExtDefaultImpl
5348b8
+policyset.cmcUserCertSet.5.default.name=AIA Extension Default
5348b8
+policyset.cmcUserCertSet.5.default.params.authInfoAccessADEnable_0=true
5348b8
+policyset.cmcUserCertSet.5.default.params.authInfoAccessADLocationType_0=URIName
5348b8
+policyset.cmcUserCertSet.5.default.params.authInfoAccessADLocation_0=
5348b8
+policyset.cmcUserCertSet.5.default.params.authInfoAccessADMethod_0=1.3.6.1.5.5.7.48.1
5348b8
+policyset.cmcUserCertSet.5.default.params.authInfoAccessCritical=false
5348b8
+policyset.cmcUserCertSet.5.default.params.authInfoAccessNumADs=1
5348b8
+policyset.cmcUserCertSet.6.constraint.class_id=keyUsageExtConstraintImpl
5348b8
+policyset.cmcUserCertSet.6.constraint.name=Key Usage Extension Constraint
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageCritical=true
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageCrlSign=false
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageDataEncipherment=false
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageDecipherOnly=false
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageDigitalSignature=true
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageEncipherOnly=false
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageKeyAgreement=true
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageKeyCertSign=false
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageKeyEncipherment=false
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageNonRepudiation=true
5348b8
+policyset.cmcUserCertSet.6.default.class_id=keyUsageExtDefaultImpl
5348b8
+policyset.cmcUserCertSet.6.default.name=Key Usage Default
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageCritical=true
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageCrlSign=false
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageDataEncipherment=false
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageDecipherOnly=false
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageDigitalSignature=true
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageEncipherOnly=false
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageKeyAgreement=true
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageKeyCertSign=false
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageKeyEncipherment=false
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageNonRepudiation=true
5348b8
+policyset.cmcUserCertSet.7.constraint.class_id=noConstraintImpl
5348b8
+policyset.cmcUserCertSet.7.constraint.name=No Constraint
5348b8
+policyset.cmcUserCertSet.7.default.class_id=extendedKeyUsageExtDefaultImpl
5348b8
+policyset.cmcUserCertSet.7.default.name=Extended Key Usage Extension Default
5348b8
+policyset.cmcUserCertSet.7.default.params.exKeyUsageCritical=false
5348b8
+policyset.cmcUserCertSet.7.default.params.exKeyUsageOIDs=1.3.6.1.5.5.7.3.2,1.3.6.1.5.5.7.3.4
5348b8
+policyset.cmcUserCertSet.8.constraint.class_id=signingAlgConstraintImpl
5348b8
+policyset.cmcUserCertSet.8.constraint.name=No Constraint
5348b8
+policyset.cmcUserCertSet.8.constraint.params.signingAlgsAllowed=SHA256withRSA,SHA512withRSA,SHA256withEC,SHA384withRSA,SHA384withEC,SHA512withEC
5348b8
+policyset.cmcUserCertSet.8.default.class_id=signingAlgDefaultImpl
5348b8
+policyset.cmcUserCertSet.8.default.name=Signing Alg
5348b8
+policyset.cmcUserCertSet.8.default.params.signingAlg=-
5348b8
diff --git a/base/ca/shared/profiles/ca/caFullCMCSelfSignedCert.cfg b/base/ca/shared/profiles/ca/caFullCMCSelfSignedCert.cfg
5348b8
deleted file mode 100644
5348b8
index 538b16a..0000000
5348b8
--- a/base/ca/shared/profiles/ca/caFullCMCSelfSignedCert.cfg
5348b8
+++ /dev/null
5348b8
@@ -1,82 +0,0 @@
5348b8
-desc=This certificate profile is for enrolling user certificates by using the self-signed CMC certificate request
5348b8
-enable=false
5348b8
-enableBy=admin
5348b8
-name=Self-Signed CMC User Certificate Enrollment
5348b8
-visible=false
5348b8
-auth.instance_id=CMCUserSignedAuth
5348b8
-input.list=i1
5348b8
-input.i1.class_id=cmcCertReqInputImpl
5348b8
-output.list=o1
5348b8
-output.o1.class_id=certOutputImpl
5348b8
-policyset.list=cmcUserCertSet
5348b8
-policyset.cmcUserCertSet.list=1,2,3,4,5,6,7,8
5348b8
-policyset.cmcUserCertSet.1.constraint.class_id=cmcSelfSignedSubjectNameConstraintImpl
5348b8
-policyset.cmcUserCertSet.1.constraint.name=CMC Self-Signed Subject Name Constraint
5348b8
-policyset.cmcUserCertSet.1.default.class_id=authTokenSubjectNameDefaultImpl
5348b8
-policyset.cmcUserCertSet.1.default.name=Subject Name Default
5348b8
-policyset.cmcUserCertSet.1.default.params.name=
5348b8
-policyset.cmcUserCertSet.2.constraint.class_id=validityConstraintImpl
5348b8
-policyset.cmcUserCertSet.2.constraint.name=Validity Constraint
5348b8
-policyset.cmcUserCertSet.2.constraint.params.notAfterCheck=false
5348b8
-policyset.cmcUserCertSet.2.constraint.params.notBeforeCheck=false
5348b8
-policyset.cmcUserCertSet.2.constraint.params.range=365
5348b8
-policyset.cmcUserCertSet.2.default.class_id=validityDefaultImpl
5348b8
-policyset.cmcUserCertSet.2.default.name=Validity Default
5348b8
-policyset.cmcUserCertSet.2.default.params.range=180
5348b8
-policyset.cmcUserCertSet.2.default.params.startTime=0
5348b8
-policyset.cmcUserCertSet.3.constraint.class_id=keyConstraintImpl
5348b8
-policyset.cmcUserCertSet.3.constraint.name=Key Constraint
5348b8
-policyset.cmcUserCertSet.3.constraint.params.keyParameters=1024,2048,3072,4096
5348b8
-policyset.cmcUserCertSet.3.constraint.params.keyType=RSA
5348b8
-policyset.cmcUserCertSet.3.default.class_id=userKeyDefaultImpl
5348b8
-policyset.cmcUserCertSet.3.default.name=Key Default
5348b8
-policyset.cmcUserCertSet.4.constraint.class_id=noConstraintImpl
5348b8
-policyset.cmcUserCertSet.4.constraint.name=No Constraint
5348b8
-policyset.cmcUserCertSet.4.default.class_id=authorityKeyIdentifierExtDefaultImpl
5348b8
-policyset.cmcUserCertSet.4.default.name=Authority Key Identifier Default
5348b8
-policyset.cmcUserCertSet.5.constraint.class_id=noConstraintImpl
5348b8
-policyset.cmcUserCertSet.5.constraint.name=No Constraint
5348b8
-policyset.cmcUserCertSet.5.default.class_id=authInfoAccessExtDefaultImpl
5348b8
-policyset.cmcUserCertSet.5.default.name=AIA Extension Default
5348b8
-policyset.cmcUserCertSet.5.default.params.authInfoAccessADEnable_0=true
5348b8
-policyset.cmcUserCertSet.5.default.params.authInfoAccessADLocationType_0=URIName
5348b8
-policyset.cmcUserCertSet.5.default.params.authInfoAccessADLocation_0=
5348b8
-policyset.cmcUserCertSet.5.default.params.authInfoAccessADMethod_0=1.3.6.1.5.5.7.48.1
5348b8
-policyset.cmcUserCertSet.5.default.params.authInfoAccessCritical=false
5348b8
-policyset.cmcUserCertSet.5.default.params.authInfoAccessNumADs=1
5348b8
-policyset.cmcUserCertSet.6.constraint.class_id=keyUsageExtConstraintImpl
5348b8
-policyset.cmcUserCertSet.6.constraint.name=Key Usage Extension Constraint
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageCritical=true
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageCrlSign=false
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageDataEncipherment=false
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageDecipherOnly=false
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageDigitalSignature=true
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageEncipherOnly=false
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageKeyAgreement=false
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageKeyCertSign=false
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageKeyEncipherment=true
5348b8
-policyset.cmcUserCertSet.6.constraint.params.keyUsageNonRepudiation=true
5348b8
-policyset.cmcUserCertSet.6.default.class_id=keyUsageExtDefaultImpl
5348b8
-policyset.cmcUserCertSet.6.default.name=Key Usage Default
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageCritical=true
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageCrlSign=false
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageDataEncipherment=false
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageDecipherOnly=false
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageDigitalSignature=true
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageEncipherOnly=false
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageKeyAgreement=false
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageKeyCertSign=false
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageKeyEncipherment=true
5348b8
-policyset.cmcUserCertSet.6.default.params.keyUsageNonRepudiation=true
5348b8
-policyset.cmcUserCertSet.7.constraint.class_id=noConstraintImpl
5348b8
-policyset.cmcUserCertSet.7.constraint.name=No Constraint
5348b8
-policyset.cmcUserCertSet.7.default.class_id=extendedKeyUsageExtDefaultImpl
5348b8
-policyset.cmcUserCertSet.7.default.name=Extended Key Usage Extension Default
5348b8
-policyset.cmcUserCertSet.7.default.params.exKeyUsageCritical=false
5348b8
-policyset.cmcUserCertSet.7.default.params.exKeyUsageOIDs=1.3.6.1.5.5.7.3.2,1.3.6.1.5.5.7.3.4
5348b8
-policyset.cmcUserCertSet.8.constraint.class_id=signingAlgConstraintImpl
5348b8
-policyset.cmcUserCertSet.8.constraint.name=No Constraint
5348b8
-policyset.cmcUserCertSet.8.constraint.params.signingAlgsAllowed=SHA256withRSA,SHA512withRSA,SHA256withEC,SHA384withRSA,SHA384withEC,SHA512withEC
5348b8
-policyset.cmcUserCertSet.8.default.class_id=signingAlgDefaultImpl
5348b8
-policyset.cmcUserCertSet.8.default.name=Signing Alg
5348b8
-policyset.cmcUserCertSet.8.default.params.signingAlg=-
5348b8
diff --git a/base/ca/shared/profiles/ca/caFullCMCSharedTokenCert.cfg b/base/ca/shared/profiles/ca/caFullCMCSharedTokenCert.cfg
5348b8
new file mode 100644
5348b8
index 0000000..5ef8004
5348b8
--- /dev/null
5348b8
+++ b/base/ca/shared/profiles/ca/caFullCMCSharedTokenCert.cfg
5348b8
@@ -0,0 +1,82 @@
5348b8
+desc=This certificate profile is for enrolling user certificates by using the CMC Shared Token certificate request
5348b8
+enable=false
5348b8
+enableBy=admin
5348b8
+name=CMC Shared Token User Certificate Enrollment
5348b8
+visible=false
5348b8
+auth.instance_id=CMCUserSignedAuth
5348b8
+input.list=i1
5348b8
+input.i1.class_id=cmcCertReqInputImpl
5348b8
+output.list=o1
5348b8
+output.o1.class_id=certOutputImpl
5348b8
+policyset.list=cmcUserCertSet
5348b8
+policyset.cmcUserCertSet.list=1,2,3,4,5,6,7,8
5348b8
+policyset.cmcUserCertSet.1.constraint.class_id=cmcSharedTokenSubjectNameConstraintImpl
5348b8
+policyset.cmcUserCertSet.1.constraint.name=CMC Shared Token Subject Name Constraint
5348b8
+policyset.cmcUserCertSet.1.default.class_id=authTokenSubjectNameDefaultImpl
5348b8
+policyset.cmcUserCertSet.1.default.name=Subject Name Default
5348b8
+policyset.cmcUserCertSet.1.default.params.name=
5348b8
+policyset.cmcUserCertSet.2.constraint.class_id=validityConstraintImpl
5348b8
+policyset.cmcUserCertSet.2.constraint.name=Validity Constraint
5348b8
+policyset.cmcUserCertSet.2.constraint.params.notAfterCheck=false
5348b8
+policyset.cmcUserCertSet.2.constraint.params.notBeforeCheck=false
5348b8
+policyset.cmcUserCertSet.2.constraint.params.range=365
5348b8
+policyset.cmcUserCertSet.2.default.class_id=validityDefaultImpl
5348b8
+policyset.cmcUserCertSet.2.default.name=Validity Default
5348b8
+policyset.cmcUserCertSet.2.default.params.range=180
5348b8
+policyset.cmcUserCertSet.2.default.params.startTime=0
5348b8
+policyset.cmcUserCertSet.3.constraint.class_id=keyConstraintImpl
5348b8
+policyset.cmcUserCertSet.3.constraint.name=Key Constraint
5348b8
+policyset.cmcUserCertSet.3.constraint.params.keyParameters=1024,2048,3072,4096
5348b8
+policyset.cmcUserCertSet.3.constraint.params.keyType=RSA
5348b8
+policyset.cmcUserCertSet.3.default.class_id=userKeyDefaultImpl
5348b8
+policyset.cmcUserCertSet.3.default.name=Key Default
5348b8
+policyset.cmcUserCertSet.4.constraint.class_id=noConstraintImpl
5348b8
+policyset.cmcUserCertSet.4.constraint.name=No Constraint
5348b8
+policyset.cmcUserCertSet.4.default.class_id=authorityKeyIdentifierExtDefaultImpl
5348b8
+policyset.cmcUserCertSet.4.default.name=Authority Key Identifier Default
5348b8
+policyset.cmcUserCertSet.5.constraint.class_id=noConstraintImpl
5348b8
+policyset.cmcUserCertSet.5.constraint.name=No Constraint
5348b8
+policyset.cmcUserCertSet.5.default.class_id=authInfoAccessExtDefaultImpl
5348b8
+policyset.cmcUserCertSet.5.default.name=AIA Extension Default
5348b8
+policyset.cmcUserCertSet.5.default.params.authInfoAccessADEnable_0=true
5348b8
+policyset.cmcUserCertSet.5.default.params.authInfoAccessADLocationType_0=URIName
5348b8
+policyset.cmcUserCertSet.5.default.params.authInfoAccessADLocation_0=
5348b8
+policyset.cmcUserCertSet.5.default.params.authInfoAccessADMethod_0=1.3.6.1.5.5.7.48.1
5348b8
+policyset.cmcUserCertSet.5.default.params.authInfoAccessCritical=false
5348b8
+policyset.cmcUserCertSet.5.default.params.authInfoAccessNumADs=1
5348b8
+policyset.cmcUserCertSet.6.constraint.class_id=keyUsageExtConstraintImpl
5348b8
+policyset.cmcUserCertSet.6.constraint.name=Key Usage Extension Constraint
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageCritical=true
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageCrlSign=false
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageDataEncipherment=false
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageDecipherOnly=false
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageDigitalSignature=true
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageEncipherOnly=false
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageKeyAgreement=false
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageKeyCertSign=false
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageKeyEncipherment=true
5348b8
+policyset.cmcUserCertSet.6.constraint.params.keyUsageNonRepudiation=true
5348b8
+policyset.cmcUserCertSet.6.default.class_id=keyUsageExtDefaultImpl
5348b8
+policyset.cmcUserCertSet.6.default.name=Key Usage Default
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageCritical=true
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageCrlSign=false
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageDataEncipherment=false
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageDecipherOnly=false
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageDigitalSignature=true
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageEncipherOnly=false
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageKeyAgreement=false
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageKeyCertSign=false
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageKeyEncipherment=true
5348b8
+policyset.cmcUserCertSet.6.default.params.keyUsageNonRepudiation=true
5348b8
+policyset.cmcUserCertSet.7.constraint.class_id=noConstraintImpl
5348b8
+policyset.cmcUserCertSet.7.constraint.name=No Constraint
5348b8
+policyset.cmcUserCertSet.7.default.class_id=extendedKeyUsageExtDefaultImpl
5348b8
+policyset.cmcUserCertSet.7.default.name=Extended Key Usage Extension Default
5348b8
+policyset.cmcUserCertSet.7.default.params.exKeyUsageCritical=false
5348b8
+policyset.cmcUserCertSet.7.default.params.exKeyUsageOIDs=1.3.6.1.5.5.7.3.2,1.3.6.1.5.5.7.3.4
5348b8
+policyset.cmcUserCertSet.8.constraint.class_id=signingAlgConstraintImpl
5348b8
+policyset.cmcUserCertSet.8.constraint.name=No Constraint
5348b8
+policyset.cmcUserCertSet.8.constraint.params.signingAlgsAllowed=SHA256withRSA,SHA512withRSA,SHA256withEC,SHA384withRSA,SHA384withEC,SHA512withEC
5348b8
+policyset.cmcUserCertSet.8.default.class_id=signingAlgDefaultImpl
5348b8
+policyset.cmcUserCertSet.8.default.name=Signing Alg
5348b8
+policyset.cmcUserCertSet.8.default.params.signingAlg=-
5348b8
diff --git a/base/java-tools/man/man1/CMCRequest.1 b/base/java-tools/man/man1/CMCRequest.1
5348b8
index 8c67fc0..18f5e50 100644
5348b8
--- a/base/java-tools/man/man1/CMCRequest.1
5348b8
+++ b/base/java-tools/man/man1/CMCRequest.1
5348b8
@@ -63,7 +63,7 @@ name of crypto token where user signing certificate key can be found (default is
5348b8
 .B nickname
5348b8
 The nickname of the user certificate that corresponds to the private key that is used to sign the request.
5348b8
 
5348b8
-This parameter is ignored if \fBselfSign\fP or \fBidentityProofV2.enable\fP is true.
5348b8
+This parameter is ignored if \fBuseSharedSecret\fP or \fBidentityProofV2.enable\fP is true.
5348b8
 
5348b8
 .TP
5348b8
 .B password
5348b8
@@ -114,27 +114,27 @@ Supported keyGenAlg are: \fBSHA-256, SHA-384, and SHA-512\fP
5348b8
 Supported macAlg are: \fBSHA-256-HMAC, SHA-384-HMAC, and SHA-512-HMAC\fP
5348b8
 
5348b8
 .TP
5348b8
-.B request.selfSign
5348b8
-\fBtrue\fP or \fBfalse\fP.  If \fBselfSign\fP is true, the CMC request will be "signed" with the pairing private key of the enrollment request; and in which case the \fBnickname\fP parameter will be ignored.
5348b8
+.B request.useSharedSecret
5348b8
+\fBtrue\fP or \fBfalse\fP.  If \fBuseSharedSecret\fP is true, the CMC request will be "signed" with the pairing private key of the enrollment request; and in which case the \fBnickname\fP parameter will be ignored.
5348b8
 
5348b8
-\fBrequest.selfSign\fP is only used if a signing certificate (of the agent or user herself) is not available to sign. Because the request itself is not signed with a certificate (a proven identity), the proof of origin (proof of identification) must be provided by some other means.
5348b8
+\fBrequest.useSharedSecret\fP is only used if a signing certificate (of the agent or user herself) is not available to sign. Because the request itself is not signed with a certificate (a proven identity), the proof of origin (proof of identification) must be provided by some other means.
5348b8
 
5348b8
-In Dogtag, if \fBselfSign\fP is true, it must be used in conjunction with the \fBidentityProofV2\fP and \fBidentification\fP parameters.  And in that case the Proof Of Origin is accomplished by the Shared Secret (\fBwitness.sharedSecret\fP) mechanism.
5348b8
+In Dogtag, if \fBrequest.useSharedSecret\fP is true, it must be used in conjunction with the \fBidentityProofV2\fP and \fBidentification\fP parameters.  And in that case the Proof Of Origin is accomplished by the Shared Secret (\fBwitness.sharedSecret\fP) mechanism.
5348b8
 
5348b8
-The \fBselfSign\fP option is normally used to enroll for a user's first signing certificate while auto-approval (without agent's pre-approval) is preferred. In general, once a user has obtained the first signing certificate, such signing certificate can be used to sign (thus proving origin) and obtain other certificate such as encryption-only ceritifcate, or when doing a renewal or revocation.
5348b8
+The \fBrequest.useSharedSecret\fP option is normally used to enroll for a user's first signing certificate while auto-approval (without agent's pre-approval) is preferred. In general, once a user has obtained the first signing certificate, such signing certificate can be used to sign (thus proving origin) and obtain other certificate such as encryption-only ceritifcate, or when doing a renewal or revocation.
5348b8
 
5348b8
-By default, if unspecified, \fBselfSign\fP is false.
5348b8
+By default, if unspecified, \fBrequest.useSharedSecret\fP is false.
5348b8
 
5348b8
-\fBNote\fP: to employ the \fBselfSign\fP option, the PKCS#10 or CRMF requests must have the \fBSubjectKeyIdentifier extension\fP. (hint: \fBCRMFPopClient\fP and \fBPKCS10Client\fP should be called with the "-y" option)
5348b8
+\fBNote\fP: to employ the \fBrequest.useSharedSecret\fP option, the PKCS#10 or CRMF requests must have the \fBSubjectKeyIdentifier extension\fP. (hint: \fBCRMFPopClient\fP and \fBPKCS10Client\fP should be called with the "-y" option)
5348b8
 
5348b8
-If \fBselfSign\fP is true, \fBrequest.privKeyId\fP must be specified.
5348b8
+If \fBrequest.useSharedSecret\fP is true, \fBrequest.privKeyId\fP must be specified.
5348b8
 It is crutial that the caller that employs this option has access to the private key of the certificate request.
5348b8
 
5348b8
 .TP
5348b8
 .B request.privKeyId
5348b8
 The \fBrequest.privKeyId\fP parameter is required in the following cases:
5348b8
 
5348b8
-\fBselfSign\fP, \fBpopLinkWitnessV2\fP, and \fBdecryptedPop\fP
5348b8
+\fBrequest.useSharedSecret\fP, \fBpopLinkWitnessV2\fP, and \fBdecryptedPop\fP
5348b8
 
5348b8
 .TP
5348b8
 .B decryptedPop.enable, encryptedPopResponseFile, decryptedPopRequestFile
5348b8
@@ -149,7 +149,7 @@ When preparing for the second trip, the following parameters must be present:
5348b8
 
5348b8
 \fBrequest.privKeyId\fP - see descripton for \fBrequest.privKeyId\fP; It is used to decrypt the EncryptedPop, thereby proving the possession of the private key.
5348b8
 
5348b8
-Please note that the \fBPopLinkWitnessV2\fP control as well as the \fBselfSign\fP directive do not apply to EncryptedPOP/DecryptedPOP for the simple fact that the enrollment private key is not capable of signing.
5348b8
+Please note that the \fBPopLinkWitnessV2\fP control as well as the \fBrequest.useSharedSecret\fP directive do not apply to EncryptedPOP/DecryptedPOP for the simple fact that the enrollment private key is not capable of signing.
5348b8
 
5348b8
 .TP
5348b8
 .B revRequest.[enable, serial, reason, comment, issuer, sharedSecret]
5348b8
diff --git a/base/java-tools/man/man1/PKCS10Client.1 b/base/java-tools/man/man1/PKCS10Client.1
5348b8
index e85c833..122680c 100644
5348b8
--- a/base/java-tools/man/man1/PKCS10Client.1
5348b8
+++ b/base/java-tools/man/man1/PKCS10Client.1
5348b8
@@ -84,7 +84,8 @@ Gives the subject DN of the certificate.
5348b8
 .B -x <true for SSL cert that does ECDH ECDSA; false otherwise; default false>
5348b8
 
5348b8
 .TP
5348b8
-.B -y <true for adding SubjectKeyIdentifier extensionfor self-signed cmc requests; false otherwise; default false>
5348b8
+.B -y <true for adding SubjectKeyIdentifier extensionfor self-signed cmc Shared Secret requests; false otherwise; default false>
5348b8
+To be used with "request.useSharedSecret=true" when running CMCRequest.
5348b8
 
5348b8
 .SH AUTHORS
5348b8
 Amol Kahat <akahat@redhat.com>.
5348b8
diff --git a/base/java-tools/src/com/netscape/cmstools/CMCRequest.java b/base/java-tools/src/com/netscape/cmstools/CMCRequest.java
5348b8
index 4e40143..1070a93 100644
5348b8
--- a/base/java-tools/src/com/netscape/cmstools/CMCRequest.java
5348b8
+++ b/base/java-tools/src/com/netscape/cmstools/CMCRequest.java
5348b8
@@ -268,13 +268,19 @@ public class CMCRequest {
5348b8
     }
5348b8
 
5348b8
     /*
5348b8
-     * signData self-signs the PKIData using the private key that matches
5348b8
-     * the public key in the request
5348b8
+     * signData self-signs (for Shared Token) the PKIData using the private key
5348b8
+     * that matches the public key in the request
5348b8
      */
5348b8
     static SignedData signData(
5348b8
             java.security.PrivateKey privKey,
5348b8
             PKIData pkidata) {
5348b8
-        String method = "signData for selfSign: ";
5348b8
+        return signData(privKey, pkidata, null);
5348b8
+    }
5348b8
+    static SignedData signData(
5348b8
+            java.security.PrivateKey privKey,
5348b8
+            PKIData pkidata,
5348b8
+            SignerIdentifier test_cmc_si /*for TEST_CMC use_shared_secret case only*/) {
5348b8
+        String method = "signData for useSharedSecret begins: ";
5348b8
         System.out.println(method + "begins: ");
5348b8
         SignedData req = null;
5348b8
 
5348b8
@@ -286,10 +292,15 @@ public class CMCRequest {
5348b8
 
5348b8
         KeyIdentifier keyIdObj = null;
5348b8
         try {
5348b8
-            keyIdObj = (KeyIdentifier) skiExtn.get(SubjectKeyIdentifierExtension.KEY_ID);
5348b8
-            SignerIdentifier si = new SignerIdentifier(
5348b8
+            SignerIdentifier si = null;
5348b8
+            if (test_cmc_si == null) {
5348b8
+                keyIdObj = (KeyIdentifier) skiExtn.get(SubjectKeyIdentifierExtension.KEY_ID);
5348b8
+                si = new SignerIdentifier(
5348b8
                     SignerIdentifier.SUBJECT_KEY_IDENTIFIER,
5348b8
                     null, new OCTET_STRING(keyIdObj.getIdentifier()));
5348b8
+            } else //TEST_CMC use_shared_secret case
5348b8
+                si = test_cmc_si;
5348b8
+
5348b8
             req = createSignedData(privKey, si, null /*certChain*/, pkidata);
5348b8
         } catch (Exception e) {
5348b8
             e.printStackTrace();
5348b8
@@ -430,7 +441,7 @@ public class CMCRequest {
5348b8
      * @return request in PKIData
5348b8
      */
5348b8
     static PKIData createPKIData(
5348b8
-            String selfSign,
5348b8
+            String useSharedSecret,
5348b8
             String[] rValue, String format, String transactionMgtEnable,
5348b8
             String transactionMgtId,
5348b8
             String identificationEnable, String identification,
5348b8
@@ -495,16 +506,16 @@ public class CMCRequest {
5348b8
 
5348b8
                         CertRequest certReq = certReqMsg.getCertReq();
5348b8
                         CertTemplate certTemplate = certReq.getCertTemplate();
5348b8
-                        if (selfSign.equals("true")) {
5348b8
+                        if (useSharedSecret.equals("true")) {
5348b8
                             skiExtn = (SubjectKeyIdentifierExtension) CryptoUtil.getExtensionFromCertTemplate(
5348b8
                                     certTemplate,
5348b8
                                     PKIXExtensions.SubjectKey_Id);
5348b8
                             if (skiExtn != null) {
5348b8
                                 System.out.println(method +
5348b8
-                                        " SubjectKeyIdentifier extension found in self-signed request");
5348b8
+                                        " SubjectKeyIdentifier extension found in self-signed Shared Token request");
5348b8
                             } else {
5348b8
                                 System.out.println(method +
5348b8
-                                        " SubjectKeyIdentifier extension missing in self-signed request");
5348b8
+                                        " SubjectKeyIdentifier extension missing in self-signed Shared Token request");
5348b8
                                 System.exit(1);
5348b8
                             }
5348b8
                         }
5348b8
@@ -569,7 +580,7 @@ public class CMCRequest {
5348b8
                             System.exit(1);
5348b8
                         }
5348b8
 
5348b8
-                        if (selfSign.equals("true")) {
5348b8
+                        if (useSharedSecret.equals("true")) {
5348b8
                             try {
5348b8
                                 skiExtn = (SubjectKeyIdentifierExtension) CryptoUtil.getExtensionFromPKCS10(
5348b8
                                         pkcs, "SubjectKeyIdentifier");
5348b8
@@ -798,13 +809,13 @@ public class CMCRequest {
5348b8
         System.out.println("#nickname: nickname for user certificate which will be used");
5348b8
         System.out.println("#to sign the CMC full request (enrollment or revocation).");
5348b8
         System.out.println("");
5348b8
-        System.out.println("#selfSign: if selfSign is true, the CMC request will be");
5348b8
+        System.out.println("#request.useSharedSecret: if request.useSharedSecret is true, the CMC request will be");
5348b8
         System.out.println("#signed with the pairing private key of the enrollment request;");
5348b8
         System.out.println("#and in which case the nickname will be ignored");
5348b8
         System.out.println("#If revRequest.sharedSecret is specified, then nickname will also be ignored.");
5348b8
         System.out.println("nickname=CMS User Signing Certificate");
5348b8
         System.out.println("");
5348b8
-        System.out.println("selfSign=false");
5348b8
+        System.out.println("request.useSharedSecret=false");
5348b8
         System.out.println("");
5348b8
         System.out.println("#dbdir: directory for cert8.db, key3.db and secmod.db");
5348b8
         System.out.println("dbdir=./");
5348b8
@@ -1219,7 +1230,7 @@ public class CMCRequest {
5348b8
  * Constructing OtherMsg to include the SignerInfo makes no sense here
5348b8
  * as the outer layer SignedData would have SignerInfo.
5348b8
  * It is possibly done because the original code assumed a self-signed
5348b8
- * revocation request that is subsequently signed by an agent...
5348b8
+ * Shared Token revocation request that is subsequently signed by an agent...
5348b8
  * which is not conforming to the RFC.
5348b8
 
5348b8
             EncapsulatedContentInfo revokeContent = new EncapsulatedContentInfo(
5348b8
@@ -1881,6 +1892,7 @@ public class CMCRequest {
5348b8
                 HMACDigest hmacDigest = new HMACDigest(SHA2Digest, challenge);
5348b8
                 hmacDigest.update(ASN1Util.encode(request));
5348b8
                 popProofValue = hmacDigest.digest();
5348b8
+                System.out.println(method + "popProofValue length = " + popProofValue.length);
5348b8
             } catch (Exception ex) {
5348b8
                 CryptoUtil.obscureBytes(challenge, "random");
5348b8
                 System.out.println(method + "calculating POP Proof Value failed: " + ex);
5348b8
@@ -1926,6 +1938,137 @@ public class CMCRequest {
5348b8
         return pkidata;
5348b8
     }
5348b8
 
5348b8
+    static void outputContentInfo(ContentInfo cmcblob, String ofilename) {
5348b8
+            try (FileOutputStream os = new FileOutputStream(ofilename)){
5348b8
+                cmcblob.encode(os);
5348b8
+                System.out.println("");
5348b8
+                System.out.println("");
5348b8
+                System.out.println("The CMC enrollment request in binary format is stored in " +
5348b8
+                        ofilename);
5348b8
+            } catch (IOException e) {
5348b8
+                System.out.println("CMCRequest:  unable to open file " + ofilename +
5348b8
+                        " for writing:\n" + e);
5348b8
+            }
5348b8
+    }
5348b8
+
5348b8
+
5348b8
+    /*
5348b8
+     *  processResignCMC
5348b8
+     *
5348b8
+     *  This is for testing only, for the purpose of producing
5348b8
+     *  negative tests consisted of deliberate alteration of
5348b8
+     *  CMC controls to see how CA reacts to these variations.
5348b8
+     *
5348b8
+     *  It takes in a blob of the format cmc (with altered fields):
5348b8
+     *      format=test_cmc
5348b8
+     *  which is the same as output format from CMCRequest,
5348b8
+     *  and re-signs it with either signerCert or privKeyID
5348b8
+     *  and spits out to output
5348b8
+     *  Note: if signerCert is not null, then privKeyID is ignored
5348b8
+     *
5348b8
+     * @author cfu
5348b8
+     */
5348b8
+    static void processResignCMC(String ifilename, String ofilename, X509Certificate signerCert, String privKeyId, String tokenName, String nickname, CryptoManager cm) {
5348b8
+        try {
5348b8
+            if (ifilename == null || ifilename.equals("")) {
5348b8
+                System.out.println("TEST_CMC: param input needed for test_cmc");
5348b8
+                System.exit(1);
5348b8
+            }
5348b8
+            if (ofilename == null || ofilename.equals("")) {
5348b8
+                System.out.println("TEST_CMC: param output needed for test_cmc");
5348b8
+                System.exit(1);
5348b8
+            }
5348b8
+
5348b8
+            PrivateKey privk = null;
5348b8
+            if (signerCert == null) {
5348b8
+                if (privKeyId == null) {
5348b8
+                    System.out.println("TEST_CMC: signerCert not supplied, need privKeyId to re-sign.");
5348b8
+                    System.exit(1);
5348b8
+                } else {
5348b8
+                    System.out.println("TEST_CMC: got re-signing privKeyId: " + privKeyId);
5348b8
+
5348b8
+                    byte[] keyIDb = CryptoUtil.decodeKeyID(privKeyId);
5348b8
+
5348b8
+                    privk = CryptoUtil.findPrivateKeyFromID(keyIDb);
5348b8
+
5348b8
+                    if (privk != null) {
5348b8
+                        System.out.println("TEST_CMC: got private key");
5348b8
+                    } else {
5348b8
+                        System.out.println("TEST_CMC: error getting private key null");
5348b8
+                        System.exit(1);
5348b8
+                    }
5348b8
+                }
5348b8
+            }
5348b8
+
5348b8
+            FileInputStream inputBlob = null;
5348b8
+            FileOutputStream outputBlob = null;
5348b8
+            try {
5348b8
+                inputBlob = new FileInputStream(ifilename);
5348b8
+            } catch (FileNotFoundException e) {
5348b8
+                System.out.println("can''t find file " +
5348b8
+                        ifilename + e);
5348b8
+                System.exit(1);
5348b8
+            }
5348b8
+
5348b8
+            byte data[] = new byte[inputBlob.available()];
5348b8
+            inputBlob.read(data);
5348b8
+            System.out.println("TEST_CMC: input read");
5348b8
+            ContentInfo.Template ci_template = new ContentInfo.Template();
5348b8
+            ContentInfo ci =
5348b8
+                    (ContentInfo) ci_template.decode(new ByteArrayInputStream(data));
5348b8
+            if (ci != null)
5348b8
+                System.out.println("TEST_CMC: ContentInfo template decoded");
5348b8
+
5348b8
+            SignedData signedData = (SignedData) ci.getInterpretedContent();
5348b8
+            if (signedData != null)
5348b8
+                System.out.println("TEST_CMC: SignedData retrieved");
5348b8
+
5348b8
+            EncapsulatedContentInfo eci = signedData.getContentInfo();
5348b8
+            if (eci != null)
5348b8
+                System.out.println("TEST_CMC: EncapsulatedContentInfo retrieved");
5348b8
+            OCTET_STRING os = eci.getContent(); //this is the orig data
5348b8
+            if (os != null)
5348b8
+                System.out.println("TEST_CMC: orig data retrieved");
5348b8
+            byte origData [] = os.toByteArray();
5348b8
+            PKIData.Template pkidata_template = new PKIData.Template();
5348b8
+            PKIData pkidata =
5348b8
+                    (PKIData) pkidata_template.decode(new ByteArrayInputStream(origData));
5348b8
+            if (pkidata != null)
5348b8
+                System.out.println("TEST_CMC: PKIData decoded");
5348b8
+
5348b8
+            // now re-sign
5348b8
+            SignedData newSignedData = null;
5348b8
+            if (signerCert != null) {
5348b8
+                System.out.println("TEST_CMC: re-signing using signer cert:" +
5348b8
+                    nickname);
5348b8
+                newSignedData = signData(signerCert, tokenName, nickname, cm, pkidata);
5348b8
+            } else { // self-signed Shared Token request
5348b8
+                System.out.println("TEST_CMC: re-signing using private key: " +
5348b8
+                    privKeyId);
5348b8
+                SET signInfos = signedData.getSignerInfos();
5348b8
+                SignerInfo si = (SignerInfo) (ASN1Util.decode(SignerInfo.getTemplate(), ASN1Util.encode(signInfos.elementAt(0))));
5348b8
+                newSignedData = signData(privk, pkidata, si.getSignerIdentifier());
5348b8
+            }
5348b8
+
5348b8
+            if (newSignedData == null) {
5348b8
+                System.out.println("TEST_CMC: PKIData signing returned null");
5348b8
+                System.exit(1);
5348b8
+            }
5348b8
+            System.out.println("TEST_CMC: PKIData signed");
5348b8
+            ContentInfo  cmcblob = getCMCBlob(newSignedData, null);
5348b8
+            if (cmcblob == null) {
5348b8
+                System.out.println("TEST_CMC: getCMCBlob returned null");
5348b8
+                System.exit(1);
5348b8
+            }
5348b8
+
5348b8
+            outputContentInfo(cmcblob, ofilename);
5348b8
+            System.out.println("TEST_CMC: completed");
5348b8
+        } catch (Exception ex) {
5348b8
+            System.out.println("TEST_CMC: exception caught: " + ex);
5348b8
+            System.exit(1);
5348b8
+        }
5348b8
+    }
5348b8
+
5348b8
     public static void main(String[] s) {
5348b8
         String numRequests = null;
5348b8
         String dbdir = null, nickname = null;
5348b8
@@ -1948,7 +2091,7 @@ public class CMCRequest {
5348b8
         String popLinkWitnessV2Enable = "false", popLinkWitnessV2keyGenAlg = "SHA256", popLinkWitnessV2macAlg = "SHA256";
5348b8
         String popLinkWitnessEnable = "false";
5348b8
         String bodyPartIDs = null, lraPopWitnessEnable = "false";
5348b8
-        String selfSign = "false";
5348b8
+        String useSharedSecret = "false";
5348b8
 
5348b8
         System.out.println("");
5348b8
 
5348b8
@@ -2009,8 +2152,9 @@ public class CMCRequest {
5348b8
                         decryptedPopEnable = val;
5348b8
                     } else if (name.equals("encryptedPopResponseFile")) {
5348b8
                         encryptedPopResponseFile = val;
5348b8
-                    } else if (name.equals("request.selfSign")) {
5348b8
-                        selfSign = val;
5348b8
+                    } else if (name.equals("request.useSharedSecret") ||
5348b8
+                        name.equals("request.selfSign")) {
5348b8
+                        useSharedSecret = val;
5348b8
                     } else if (name.equals("request.privKeyId")) {
5348b8
                         privKeyId = val;
5348b8
                     } else if (name.equals("decryptedPopRequestFile")) {
5348b8
@@ -2095,12 +2239,13 @@ public class CMCRequest {
5348b8
             printUsage();
5348b8
         }
5348b8
 
5348b8
-        if ((!selfSign.equals("true") && (revRequestSharedSecret == null))
5348b8
+        if ((!useSharedSecret.equals("true") && (revRequestSharedSecret == null))
5348b8
                 && nickname == null) {
5348b8
             System.out.println("Missing nickname.");
5348b8
             printUsage();
5348b8
         }
5348b8
 
5348b8
+
5348b8
         try {
5348b8
             // initialize CryptoManager
5348b8
             if (dbdir == null)
5348b8
@@ -2142,7 +2287,7 @@ public class CMCRequest {
5348b8
                 certname.append(tokenName);
5348b8
                 certname.append(":");
5348b8
             }
5348b8
-            if ((!selfSign.equals("true") || (revRequestSharedSecret == null))
5348b8
+            if ((!useSharedSecret.equals("true") || (revRequestSharedSecret == null))
5348b8
                     && nickname != null) {
5348b8
                 certname.append(nickname);
5348b8
                 signerCert = cm.findCertByNickname(certname.toString());
5348b8
@@ -2151,14 +2296,22 @@ public class CMCRequest {
5348b8
                 }
5348b8
             }
5348b8
 
5348b8
+            // TEST_CMC
5348b8
+            if (format.equals("test_cmc")) {
5348b8
+                System.out.println("TEST_CMC: request format is test_cmc; re-signing the request");
5348b8
+                processResignCMC(ifilename, ofilename, signerCert, privKeyId,
5348b8
+                        tokenName, nickname, cm);
5348b8
+                System.exit(0);
5348b8
+            }
5348b8
+
5348b8
             ContentInfo cmcblob = null;
5348b8
             PKIData pkidata = null;
5348b8
             PrivateKey privk = null;
5348b8
-            if (selfSign.equalsIgnoreCase("true") ||
5348b8
+            if (useSharedSecret.equalsIgnoreCase("true") ||
5348b8
                     decryptedPopEnable.equalsIgnoreCase("true") ||
5348b8
                     popLinkWitnessV2Enable.equalsIgnoreCase("true")) {
5348b8
                 if (privKeyId == null) {
5348b8
-                    System.out.println("selfSign or ecryptedPop.enable or popLinkWitnessV2 true, but privKeyId not specified.");
5348b8
+                    System.out.println("useSharedSecret or ecryptedPop.enable or popLinkWitnessV2 true, but privKeyId not specified.");
5348b8
                     printUsage();
5348b8
                 } else {
5348b8
                     System.out.println("got request privKeyId: " + privKeyId);
5348b8
@@ -2353,7 +2506,7 @@ public class CMCRequest {
5348b8
 
5348b8
                     // create the request PKIData
5348b8
                     pkidata = createPKIData(
5348b8
-                        selfSign,
5348b8
+                        useSharedSecret,
5348b8
                         requests,
5348b8
                         format, transactionMgtEnable, transactionMgtId,
5348b8
                         identificationEnable, identification,
5348b8
@@ -2381,13 +2534,13 @@ public class CMCRequest {
5348b8
                 SignedData signedData = null;
5348b8
 
5348b8
                 // sign the request
5348b8
-                if (selfSign.equalsIgnoreCase("true")) {
5348b8
-                    // selfSign signs with private key
5348b8
-                    System.out.println("selfSign is true...");
5348b8
+                if (useSharedSecret.equalsIgnoreCase("true")) {
5348b8
+                    // useSharedSecret signs with private key
5348b8
+                    System.out.println("useSharedSecret is true...");
5348b8
                     signedData = signData(privk, pkidata);
5348b8
                 } else {
5348b8
-                    // none selfSign signs with  existing cert
5348b8
-                    System.out.println("selfSign is false...");
5348b8
+                    // none useSharedSecret signs with  existing cert
5348b8
+                    System.out.println("useSharedSecret is false...");
5348b8
                     signedData = signData(signerCert, tokenName, nickname, cm, pkidata);
5348b8
                 }
5348b8
                 if (signedData == null) {
5348b8
@@ -2404,27 +2557,7 @@ public class CMCRequest {
5348b8
 
5348b8
             // (6) Finally, print the actual CMC blob to the
5348b8
             //     specified output file
5348b8
-            FileOutputStream os = null;
5348b8
-            try {
5348b8
-                os = new FileOutputStream(ofilename);
5348b8
-                cmcblob.encode(os);
5348b8
-                System.out.println("");
5348b8
-                System.out.println("");
5348b8
-                System.out.println("The CMC enrollment request in binary format is stored in " +
5348b8
-                        ofilename);
5348b8
-            } catch (IOException e) {
5348b8
-                System.out.println("CMCRequest:  unable to open file " + ofilename +
5348b8
-                        " for writing:\n" + e);
5348b8
-            }
5348b8
-
5348b8
-            try {
5348b8
-                os.close();
5348b8
-            } catch (IOException e) {
5348b8
-                System.out.println("CMCRequest:  Unexpected error " +
5348b8
-                        "encountered while attempting to close() " +
5348b8
-                        "\n" + e);
5348b8
-            }
5348b8
-
5348b8
+            outputContentInfo(cmcblob, ofilename);
5348b8
         } catch (Exception e) {
5348b8
             e.printStackTrace();
5348b8
             System.exit(1);
5348b8
diff --git a/base/java-tools/src/com/netscape/cmstools/CRMFPopClient.java b/base/java-tools/src/com/netscape/cmstools/CRMFPopClient.java
5348b8
index 747b7d6..dd7a264 100644
5348b8
--- a/base/java-tools/src/com/netscape/cmstools/CRMFPopClient.java
5348b8
+++ b/base/java-tools/src/com/netscape/cmstools/CRMFPopClient.java
5348b8
@@ -190,7 +190,7 @@ public class CRMFPopClient {
5348b8
         option.setArgName("keywrap algorithm");
5348b8
         options.addOption(option);
5348b8
 
5348b8
-        options.addOption("y", false, "for Self-signed cmc.");
5348b8
+        options.addOption("y", false, "for cmc SharedSecret requests.");
5348b8
 
5348b8
         options.addOption("v", "verbose", false, "Run in verbose mode.");
5348b8
         options.addOption(null, "help", false, "Show help message.");
5348b8
@@ -210,7 +210,7 @@ public class CRMFPopClient {
5348b8
         System.out.println("  -k <true|false>              Attribute value encoding in subject DN (default: false)");
5348b8
         System.out.println("                               - true: enabled");
5348b8
         System.out.println("                               - false: disabled");
5348b8
-        System.out.println("  -y <true|false>              Add SubjectKeyIdentifier extension in case of self-signed CMC requests (default: false)");
5348b8
+        System.out.println("  -y <true|false>              Add SubjectKeyIdentifier extension in case of CMC SharedSecret requests (default: false); To be used with 'request.useSharedSecret=true' when running CMCRequest.");
5348b8
         System.out.println("                               - true: enabled");
5348b8
         System.out.println("                               - false: disabled");
5348b8
         System.out.println("  -a <rsa|ec>                  Key algorithm (default: rsa)");
5348b8
@@ -320,7 +320,7 @@ public class CRMFPopClient {
5348b8
         int sensitive = Integer.parseInt(cmd.getOptionValue("s", "-1"));
5348b8
         int extractable = Integer.parseInt(cmd.getOptionValue("e", "-1"));
5348b8
 
5348b8
-        boolean self_sign = cmd.hasOption("y");
5348b8
+        boolean use_shared_secret = cmd.hasOption("y");
5348b8
 
5348b8
         // get the keywrap algorithm
5348b8
         KeyWrapAlgorithm keyWrapAlgorithm = null;
5348b8
@@ -335,6 +335,7 @@ public class CRMFPopClient {
5348b8
         }
5348b8
 
5348b8
         String output = cmd.getOptionValue("o");
5348b8
+        String output_kid = output + ".keyId";
5348b8
 
5348b8
         String hostPort = cmd.getOptionValue("m");
5348b8
         String username = cmd.getOptionValue("u");
5348b8
@@ -507,7 +508,7 @@ public class CRMFPopClient {
5348b8
 
5348b8
             if (verbose) System.out.println("Creating certificate request");
5348b8
             CertRequest certRequest = client.createCertRequest(
5348b8
-                    self_sign,
5348b8
+                    use_shared_secret,
5348b8
                     token, transportCert, algorithm, keyPair,
5348b8
                     subject, keyWrapAlgorithm);
5348b8
 
5348b8
@@ -558,11 +559,16 @@ public class CRMFPopClient {
5348b8
                         requestor);
5348b8
 
5348b8
             } else if (output != null) {
5348b8
-                System.out.println("Storing CRMF requrest into " + output);
5348b8
+                System.out.println("Storing CRMF request into " + output);
5348b8
                 try (FileWriter out = new FileWriter(output)) {
5348b8
                     out.write(csr);
5348b8
                 }
5348b8
 
5348b8
+                System.out.println("Storing CRMF request key id into " + output_kid);
5348b8
+                try (FileWriter out_kid = new FileWriter(output_kid)) {
5348b8
+                    out_kid.write(kid);
5348b8
+                }
5348b8
+
5348b8
             } else {
5348b8
                 System.out.println(csr);
5348b8
             }
5348b8
@@ -655,7 +661,7 @@ public class CRMFPopClient {
5348b8
     }
5348b8
 
5348b8
     public CertRequest createCertRequest(
5348b8
-            boolean self_sign,
5348b8
+            boolean use_shared_secret,
5348b8
             CryptoToken token,
5348b8
             X509Certificate transportCert,
5348b8
             String algorithm,
5348b8
@@ -701,8 +707,8 @@ public class CRMFPopClient {
5348b8
         seq.addElement(new AVA(OBJECT_IDENTIFIER.id_cmc_idPOPLinkWitness, ostr));
5348b8
         */
5348b8
 
5348b8
-        if (self_sign) { // per rfc 5272
5348b8
-            System.out.println("CRMFPopClient: self_sign true. Generating SubjectKeyIdentifier extension.");
5348b8
+        if (use_shared_secret) { // per rfc 5272
5348b8
+            System.out.println("CRMFPopClient: use_shared_secret true. Generating SubjectKeyIdentifier extension.");
5348b8
             KeyIdentifier subjKeyId = CryptoUtil.createKeyIdentifier(keyPair);
5348b8
             OBJECT_IDENTIFIER oid = new OBJECT_IDENTIFIER(PKIXExtensions.SubjectKey_Id.toString());
5348b8
             SEQUENCE extns = new SEQUENCE();
5348b8
diff --git a/base/java-tools/src/com/netscape/cmstools/PKCS10Client.java b/base/java-tools/src/com/netscape/cmstools/PKCS10Client.java
5348b8
index 9f39430..137049e 100644
5348b8
--- a/base/java-tools/src/com/netscape/cmstools/PKCS10Client.java
5348b8
+++ b/base/java-tools/src/com/netscape/cmstools/PKCS10Client.java
5348b8
@@ -18,6 +18,7 @@
5348b8
 package com.netscape.cmstools;
5348b8
 
5348b8
 import java.io.FileOutputStream;
5348b8
+import java.io.FileWriter;
5348b8
 import java.io.IOException;
5348b8
 import java.io.PrintStream;
5348b8
 import java.security.KeyPair;
5348b8
@@ -84,11 +85,11 @@ public class PKCS10Client {
5348b8
         System.out.println(
5348b8
                 "   available ECC curve names (if provided by the crypto module): nistp256 (secp256r1),nistp384 (secp384r1),nistp521 (secp521r1),nistk163 (sect163k1),sect163r1,nistb163 (sect163r2),sect193r1,sect193r2,nistk233 (sect233k1),nistb233 (sect233r1),sect239k1,nistk283 (sect283k1),nistb283 (sect283r1),nistk409 (sect409k1),nistb409 (sect409r1),nistk571 (sect571k1),nistb571 (sect571r1),secp160k1,secp160r1,secp160r2,secp192k1,nistp192 (secp192r1, prime192v1),secp224k1,nistp224 (secp224r1),secp256k1,prime192v2,prime192v3,prime239v1,prime239v2,prime239v3,c2pnb163v1,c2pnb163v2,c2pnb163v3,c2pnb176v1,c2tnb191v1,c2tnb191v2,c2tnb191v3,c2pnb208w1,c2tnb239v1,c2tnb239v2,c2tnb239v3,c2pnb272w1,c2pnb304w1,c2tnb359w1,c2pnb368w1,c2tnb431r1,secp112r1,secp112r2,secp128r1,secp128r2,sect113r1,sect113r2,sect131r1,sect131r2\n");
5348b8
         System.out.println(
5348b8
-                "In addition: -y <true for adding SubjectKeyIdentifier extensionfor self-signed cmc requests; false otherwise; default false>\n");
5348b8
+                "In addition: -y <true for adding SubjectKeyIdentifier extensionfor cmc Shared Secret requests; false otherwise; default false> To be used with 'request.useSharedSecret=true' when running CMCRequest.\n");
5348b8
     }
5348b8
 
5348b8
     public static void main(String args[]) throws Exception {
5348b8
-        String dbdir = null, ofilename = null, password = null, subjectName = null, tokenName = null;
5348b8
+        String dbdir = null, ofilename = null, kid_ofilename = null, password = null, subjectName = null, tokenName = null;
5348b8
 
5348b8
         String alg = "rsa";
5348b8
         String ecc_curve = "nistp256";
5348b8
@@ -99,7 +100,7 @@ public class PKCS10Client {
5348b8
         boolean ec_ssl_ecdh = false;
5348b8
         int rsa_keylen = 2048;
5348b8
 
5348b8
-        boolean self_sign = false;
5348b8
+        boolean use_shared_secret = false;
5348b8
 
5348b8
         if (args.length < 4) {
5348b8
             printUsage();
5348b8
@@ -163,6 +164,7 @@ public class PKCS10Client {
5348b8
                 rsa_keylen = Integer.parseInt(args[i+1]);
5348b8
             } else if (name.equals("-o")) {
5348b8
                 ofilename = args[i+1];
5348b8
+                kid_ofilename = ofilename + ".keyId";
5348b8
             } else if (name.equals("-n")) {
5348b8
                 subjectName = args[i+1];
5348b8
             } else if (name.equals("-h")) {
5348b8
@@ -170,9 +172,9 @@ public class PKCS10Client {
5348b8
             } else if (name.equals("-y")) {
5348b8
                 String temp = args[i+1];
5348b8
                 if (temp.equals("true"))
5348b8
-                    self_sign = true;
5348b8
+                    use_shared_secret = true;
5348b8
                 else
5348b8
-                    self_sign = false;
5348b8
+                    use_shared_secret = false;
5348b8
             } else {
5348b8
                 System.out.println("Unrecognized argument(" + i + "): "
5348b8
                     + name);
5348b8
@@ -277,8 +279,8 @@ public class PKCS10Client {
5348b8
 
5348b8
 
5348b8
             Extensions extns = new Extensions();
5348b8
-            if (self_sign) { // per rfc 5272
5348b8
-                System.out.println("PKCS10Client: self_sign true. Generating SubjectKeyIdentifier extension.");
5348b8
+            if (use_shared_secret) { // per rfc 5272
5348b8
+                System.out.println("PKCS10Client: use_shared_secret true. Generating SubjectKeyIdentifier extension.");
5348b8
                 KeyIdentifier subjKeyId = CryptoUtil.createKeyIdentifier(pair);
5348b8
                 SubjectKeyIdentifierExtension extn = new SubjectKeyIdentifierExtension(false,
5348b8
                         subjKeyId.getIdentifier());
5348b8
@@ -318,7 +320,13 @@ public class PKCS10Client {
5348b8
             ps.println(Cert.REQUEST_FOOTER);
5348b8
             ps.flush();
5348b8
             ps.close();
5348b8
-            System.out.println("PKCS10Client: done. Request written to file: "+ ofilename);
5348b8
+            System.out.println("PKCS10Client: done. Certificate request written into "+ ofilename);
5348b8
+
5348b8
+            try (FileWriter out_kid = new FileWriter(kid_ofilename)) {
5348b8
+                out_kid.write(kid);
5348b8
+            }
5348b8
+            System.out.println("PKCS10Client: PKCS#10 request key id written into " + kid_ofilename);
5348b8
+
5348b8
         } catch (Exception e) {
5348b8
             System.out.println("PKCS10Client: Exception caught: "+e.toString());
5348b8
             System.exit(1);
5348b8
diff --git a/base/server/cms/src/com/netscape/cms/profile/constraint/CMCSelfSignedSubjectNameConstraint.java b/base/server/cms/src/com/netscape/cms/profile/constraint/CMCSelfSignedSubjectNameConstraint.java
5348b8
deleted file mode 100644
5348b8
index d4554ca..0000000
5348b8
--- a/base/server/cms/src/com/netscape/cms/profile/constraint/CMCSelfSignedSubjectNameConstraint.java
5348b8
+++ /dev/null
5348b8
@@ -1,129 +0,0 @@
5348b8
-// --- BEGIN COPYRIGHT BLOCK ---
5348b8
-// This program is free software; you can redistribute it and/or modify
5348b8
-// it under the terms of the GNU General Public License as published by
5348b8
-// the Free Software Foundation; version 2 of the License.
5348b8
-//
5348b8
-// This program is distributed in the hope that it will be useful,
5348b8
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
5348b8
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5348b8
-// GNU General Public License for more details.
5348b8
-//
5348b8
-// You should have received a copy of the GNU General Public License along
5348b8
-// with this program; if not, write to the Free Software Foundation, Inc.,
5348b8
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
5348b8
-//
5348b8
-// (C) 2013 Red Hat, Inc.
5348b8
-// All rights reserved.
5348b8
-// --- END COPYRIGHT BLOCK ---
5348b8
-package com.netscape.cms.profile.constraint;
5348b8
-
5348b8
-import java.util.Locale;
5348b8
-
5348b8
-import com.netscape.certsrv.apps.CMS;
5348b8
-import com.netscape.certsrv.authentication.IAuthToken;
5348b8
-import com.netscape.certsrv.authentication.IAuthManager;
5348b8
-import com.netscape.certsrv.base.IConfigStore;
5348b8
-import com.netscape.certsrv.profile.EProfileException;
5348b8
-import com.netscape.certsrv.profile.ERejectException;
5348b8
-import com.netscape.certsrv.profile.IPolicyDefault;
5348b8
-import com.netscape.certsrv.profile.IProfile;
5348b8
-import com.netscape.certsrv.property.IDescriptor;
5348b8
-import com.netscape.certsrv.request.IRequest;
5348b8
-import com.netscape.cms.profile.common.EnrollProfile;
5348b8
-import com.netscape.cms.profile.def.AuthTokenSubjectNameDefault;
5348b8
-
5348b8
-import netscape.security.x509.CertificateSubjectName;
5348b8
-import netscape.security.x509.X500Name;
5348b8
-import netscape.security.x509.X509CertInfo;
5348b8
-
5348b8
-/**
5348b8
- * This class implements the user subject name constraint for self-signed cmc requests.
5348b8
- * It makes sure the SharedSecret authenticated subjectDN and the rsulting cert match
5348b8
- *
5348b8
- * @author cfu
5348b8
- * @version $Revision$, $Date$
5348b8
- */
5348b8
-public class CMCSelfSignedSubjectNameConstraint extends EnrollConstraint {
5348b8
-
5348b8
-    public CMCSelfSignedSubjectNameConstraint() {
5348b8
-    }
5348b8
-
5348b8
-    public void init(IProfile profile, IConfigStore config)
5348b8
-            throws EProfileException {
5348b8
-        super.init(profile, config);
5348b8
-    }
5348b8
-
5348b8
-    public IDescriptor getConfigDescriptor(Locale locale, String name) {
5348b8
-        return null;
5348b8
-    }
5348b8
-
5348b8
-    public String getDefaultConfig(String name) {
5348b8
-        return null;
5348b8
-    }
5348b8
-
5348b8
-    /**
5348b8
-     * Validates the request. The request is not modified
5348b8
-     * during the validation. User encoded subject name
5348b8
-     * is copied into the certificate template.
5348b8
-     */
5348b8
-    public void validate(IRequest request, X509CertInfo info)
5348b8
-            throws ERejectException {
5348b8
-        String method = "CMCSelfSignedSubjectNameConstraint: ";
5348b8
-        String msg = "";
5348b8
-
5348b8
-        CertificateSubjectName infoCertSN = null;
5348b8
-        String authTokenSharedTokenSN = null;
5348b8
-
5348b8
-        try {
5348b8
-            infoCertSN = (CertificateSubjectName) info.get(X509CertInfo.SUBJECT);
5348b8
-            if (infoCertSN == null) {
5348b8
-                msg = method + "infoCertSN null";
5348b8
-                CMS.debug(msg);
5348b8
-                throw new Exception(msg);
5348b8
-            }
5348b8
-            CMS.debug(method + "validate user subject ="+
5348b8
-                      infoCertSN.toString());
5348b8
-            X500Name infoCertName = (X500Name) infoCertSN.get(CertificateSubjectName.DN_NAME);
5348b8
-            if (infoCertName == null) {
5348b8
-                msg = method + "infoCertName null";
5348b8
-                CMS.debug(msg);
5348b8
-                throw new Exception(msg);
5348b8
-            }
5348b8
-
5348b8
-            authTokenSharedTokenSN = request.getExtDataInString(IAuthToken.TOKEN_SHARED_TOKEN_AUTHENTICATED_CERT_SUBJECT);
5348b8
-            if (authTokenSharedTokenSN == null) {
5348b8
-                msg = method + "authTokenSharedTokenSN null";
5348b8
-                CMS.debug(msg);
5348b8
-                throw new Exception(msg);
5348b8
-            }
5348b8
-            if (infoCertName.getName().equalsIgnoreCase(authTokenSharedTokenSN)) {
5348b8
-                CMS.debug(method + "names matched");
5348b8
-            } else {
5348b8
-                msg = method + "names do not match; authTokenSharedTokenSN =" +
5348b8
-                        authTokenSharedTokenSN;
5348b8
-                CMS.debug(msg);
5348b8
-                throw new Exception(msg);
5348b8
-            }
5348b8
-
5348b8
-        } catch (Exception e) {
5348b8
-            throw new ERejectException(
5348b8
-                    CMS.getUserMessage(getLocale(request),
5348b8
-                        "CMS_PROFILE_SUBJECT_NAME_NOT_MATCHED") + e);
5348b8
-        }
5348b8
-    }
5348b8
-
5348b8
-    public String getText(Locale locale) {
5348b8
-        return CMS.getUserMessage(locale,
5348b8
-                   "CMS_PROFILE_CONSTRAINT_CMC_SELF_SIGNED_SUBJECT_NAME_TEXT");
5348b8
-    }
5348b8
-
5348b8
-    public boolean isApplicable(IPolicyDefault def) {
5348b8
-        String method = "CMCSelfSignedSubjectNameConstraint: isApplicable: ";
5348b8
-        if (def instanceof AuthTokenSubjectNameDefault) {
5348b8
-            CMS.debug(method + "true");
5348b8
-            return true;
5348b8
-        }
5348b8
-        CMS.debug(method + "false");
5348b8
-        return false;
5348b8
-    }
5348b8
-}
5348b8
diff --git a/base/server/cms/src/com/netscape/cms/profile/constraint/CMCSharedTokenSubjectNameConstraint.java b/base/server/cms/src/com/netscape/cms/profile/constraint/CMCSharedTokenSubjectNameConstraint.java
5348b8
new file mode 100644
5348b8
index 0000000..879e1cc
5348b8
--- /dev/null
5348b8
+++ b/base/server/cms/src/com/netscape/cms/profile/constraint/CMCSharedTokenSubjectNameConstraint.java
5348b8
@@ -0,0 +1,130 @@
5348b8
+// --- BEGIN COPYRIGHT BLOCK ---
5348b8
+// This program is free software; you can redistribute it and/or modify
5348b8
+// it under the terms of the GNU General Public License as published by
5348b8
+// the Free Software Foundation; version 2 of the License.
5348b8
+//
5348b8
+// This program is distributed in the hope that it will be useful,
5348b8
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
5348b8
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5348b8
+// GNU General Public License for more details.
5348b8
+//
5348b8
+// You should have received a copy of the GNU General Public License along
5348b8
+// with this program; if not, write to the Free Software Foundation, Inc.,
5348b8
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
5348b8
+//
5348b8
+// (C) 2013 Red Hat, Inc.
5348b8
+// All rights reserved.
5348b8
+// --- END COPYRIGHT BLOCK ---
5348b8
+package com.netscape.cms.profile.constraint;
5348b8
+
5348b8
+import java.util.Locale;
5348b8
+
5348b8
+import com.netscape.certsrv.apps.CMS;
5348b8
+import com.netscape.certsrv.authentication.IAuthToken;
5348b8
+import com.netscape.certsrv.authentication.IAuthManager;
5348b8
+import com.netscape.certsrv.base.IConfigStore;
5348b8
+import com.netscape.certsrv.profile.EProfileException;
5348b8
+import com.netscape.certsrv.profile.ERejectException;
5348b8
+import com.netscape.certsrv.profile.IPolicyDefault;
5348b8
+import com.netscape.certsrv.profile.IProfile;
5348b8
+import com.netscape.certsrv.property.IDescriptor;
5348b8
+import com.netscape.certsrv.request.IRequest;
5348b8
+import com.netscape.cms.profile.common.EnrollProfile;
5348b8
+import com.netscape.cms.profile.def.AuthTokenSubjectNameDefault;
5348b8
+
5348b8
+import netscape.security.x509.CertificateSubjectName;
5348b8
+import netscape.security.x509.X500Name;
5348b8
+import netscape.security.x509.X509CertInfo;
5348b8
+
5348b8
+/**
5348b8
+ * This class implements the user subject name constraint for cmc requests
5348b8
+ * authenticated by the SharedSecret
5348b8
+ * The resulting cert should match that of the authenticating DN
5348b8
+ *
5348b8
+ * @author cfu
5348b8
+ * @version $Revision$, $Date$
5348b8
+ */
5348b8
+public class CMCSharedTokenSubjectNameConstraint extends EnrollConstraint {
5348b8
+
5348b8
+    public CMCSharedTokenSubjectNameConstraint() {
5348b8
+    }
5348b8
+
5348b8
+    public void init(IProfile profile, IConfigStore config)
5348b8
+            throws EProfileException {
5348b8
+        super.init(profile, config);
5348b8
+    }
5348b8
+
5348b8
+    public IDescriptor getConfigDescriptor(Locale locale, String name) {
5348b8
+        return null;
5348b8
+    }
5348b8
+
5348b8
+    public String getDefaultConfig(String name) {
5348b8
+        return null;
5348b8
+    }
5348b8
+
5348b8
+    /**
5348b8
+     * Validates the request. The request is not modified
5348b8
+     * during the validation. User encoded subject name
5348b8
+     * is copied into the certificate template.
5348b8
+     */
5348b8
+    public void validate(IRequest request, X509CertInfo info)
5348b8
+            throws ERejectException {
5348b8
+        String method = "CMCSharedTokenSubjectNameConstraint: ";
5348b8
+        String msg = "";
5348b8
+
5348b8
+        CertificateSubjectName infoCertSN = null;
5348b8
+        String authTokenSharedTokenSN = null;
5348b8
+
5348b8
+        try {
5348b8
+            infoCertSN = (CertificateSubjectName) info.get(X509CertInfo.SUBJECT);
5348b8
+            if (infoCertSN == null) {
5348b8
+                msg = method + "infoCertSN null";
5348b8
+                CMS.debug(msg);
5348b8
+                throw new Exception(msg);
5348b8
+            }
5348b8
+            CMS.debug(method + "validate user subject ="+
5348b8
+                      infoCertSN.toString());
5348b8
+            X500Name infoCertName = (X500Name) infoCertSN.get(CertificateSubjectName.DN_NAME);
5348b8
+            if (infoCertName == null) {
5348b8
+                msg = method + "infoCertName null";
5348b8
+                CMS.debug(msg);
5348b8
+                throw new Exception(msg);
5348b8
+            }
5348b8
+
5348b8
+            authTokenSharedTokenSN = request.getExtDataInString(IAuthToken.TOKEN_SHARED_TOKEN_AUTHENTICATED_CERT_SUBJECT);
5348b8
+            if (authTokenSharedTokenSN == null) {
5348b8
+                msg = method + "authTokenSharedTokenSN null";
5348b8
+                CMS.debug(msg);
5348b8
+                throw new Exception(msg);
5348b8
+            }
5348b8
+            if (infoCertName.getName().equalsIgnoreCase(authTokenSharedTokenSN)) {
5348b8
+                CMS.debug(method + "names matched");
5348b8
+            } else {
5348b8
+                msg = method + "names do not match; authTokenSharedTokenSN =" +
5348b8
+                        authTokenSharedTokenSN;
5348b8
+                CMS.debug(msg);
5348b8
+                throw new Exception(msg);
5348b8
+            }
5348b8
+
5348b8
+        } catch (Exception e) {
5348b8
+            throw new ERejectException(
5348b8
+                    CMS.getUserMessage(getLocale(request),
5348b8
+                        "CMS_PROFILE_SUBJECT_NAME_NOT_MATCHED") + e);
5348b8
+        }
5348b8
+    }
5348b8
+
5348b8
+    public String getText(Locale locale) {
5348b8
+        return CMS.getUserMessage(locale,
5348b8
+                   "CMS_PROFILE_CONSTRAINT_CMC_SELF_SIGNED_SUBJECT_NAME_TEXT");
5348b8
+    }
5348b8
+
5348b8
+    public boolean isApplicable(IPolicyDefault def) {
5348b8
+        String method = "CMCSharedTokenSubjectNameConstraint: isApplicable: ";
5348b8
+        if (def instanceof AuthTokenSubjectNameDefault) {
5348b8
+            CMS.debug(method + "true");
5348b8
+            return true;
5348b8
+        }
5348b8
+        CMS.debug(method + "false");
5348b8
+        return false;
5348b8
+    }
5348b8
+}
5348b8
-- 
5348b8
1.8.3.1
5348b8