|
|
dd68f4 |
From ea4121886b2f8d9f2de34edcb20b1a9caae9c2c5 Mon Sep 17 00:00:00 2001
|
|
|
dd68f4 |
From: "Endi S. Dewata" <edewata@redhat.com>
|
|
|
dd68f4 |
Date: Tue, 15 Nov 2016 21:32:53 +0100
|
|
|
dd68f4 |
Subject: [PATCH 1/2] Fixed problem installing subordinate CA with HSM in FIPS
|
|
|
dd68f4 |
mode.
|
|
|
dd68f4 |
|
|
|
dd68f4 |
Due to certutil issue (bug #1393668) the installation code has
|
|
|
dd68f4 |
been modified to import certificates into the NSS database in
|
|
|
dd68f4 |
two steps. This workaround is needed to install subordinate CA
|
|
|
dd68f4 |
with HSM in FIPS mode.
|
|
|
dd68f4 |
|
|
|
dd68f4 |
First, the certificate will be imported into the HSM using the
|
|
|
dd68f4 |
HSM password without the trust attributes. Then, the certificate
|
|
|
dd68f4 |
will be imported into the internal token using the internal token
|
|
|
dd68f4 |
password with the trust attributes.
|
|
|
dd68f4 |
|
|
|
dd68f4 |
https://fedorahosted.org/pki/ticket/2543
|
|
|
dd68f4 |
(cherry picked from commit 0bef3bbcc5c5cb2d6fb3f0d231c4f5b7fac5ca3b)
|
|
|
dd68f4 |
(cherry picked from commit b058ded6f9708edc601041077339947f0f87c19f)
|
|
|
dd68f4 |
---
|
|
|
dd68f4 |
base/common/python/pki/nssdb.py | 51 ++++++++++++++++++++++++-------
|
|
|
dd68f4 |
base/server/python/pki/server/__init__.py | 3 +-
|
|
|
dd68f4 |
2 files changed, 42 insertions(+), 12 deletions(-)
|
|
|
dd68f4 |
|
|
|
dd68f4 |
diff --git a/base/common/python/pki/nssdb.py b/base/common/python/pki/nssdb.py
|
|
|
dd68f4 |
index 736efca..0a674c0 100644
|
|
|
dd68f4 |
--- a/base/common/python/pki/nssdb.py
|
|
|
dd68f4 |
+++ b/base/common/python/pki/nssdb.py
|
|
|
dd68f4 |
@@ -99,7 +99,8 @@ def get_file_type(filename):
|
|
|
dd68f4 |
|
|
|
dd68f4 |
class NSSDatabase(object):
|
|
|
dd68f4 |
|
|
|
dd68f4 |
- def __init__(self, directory=None, token=None, password=None, password_file=None):
|
|
|
dd68f4 |
+ def __init__(self, directory=None, token=None, password=None, password_file=None,
|
|
|
dd68f4 |
+ internal_password=None, internal_password_file=None):
|
|
|
dd68f4 |
|
|
|
dd68f4 |
if not directory:
|
|
|
dd68f4 |
directory = os.path.join(os.path.expanduser("~"), '.dogtag', 'nssdb')
|
|
|
dd68f4 |
@@ -124,25 +125,53 @@ class NSSDatabase(object):
|
|
|
dd68f4 |
else:
|
|
|
dd68f4 |
raise Exception('Missing NSS database password')
|
|
|
dd68f4 |
|
|
|
dd68f4 |
+ if internal_password:
|
|
|
dd68f4 |
+ # Store the specified internal token into password file.
|
|
|
dd68f4 |
+ self.internal_password_file = os.path.join(self.tmpdir, 'internal_password.txt')
|
|
|
dd68f4 |
+ with open(self.internal_password_file, 'w') as f:
|
|
|
dd68f4 |
+ f.write(internal_password)
|
|
|
dd68f4 |
+
|
|
|
dd68f4 |
+ elif internal_password_file:
|
|
|
dd68f4 |
+ # Use the specified internal token password file.
|
|
|
dd68f4 |
+ self.internal_password_file = internal_password_file
|
|
|
dd68f4 |
+
|
|
|
dd68f4 |
+ else:
|
|
|
dd68f4 |
+ # By default use the same password for both internal token and HSM.
|
|
|
dd68f4 |
+ self.internal_password_file = self.password_file
|
|
|
dd68f4 |
+
|
|
|
dd68f4 |
def close(self):
|
|
|
dd68f4 |
shutil.rmtree(self.tmpdir)
|
|
|
dd68f4 |
|
|
|
dd68f4 |
def add_cert(self, nickname, cert_file, trust_attributes=',,'):
|
|
|
dd68f4 |
- cmd = [
|
|
|
dd68f4 |
- 'certutil',
|
|
|
dd68f4 |
- '-A',
|
|
|
dd68f4 |
- '-d', self.directory
|
|
|
dd68f4 |
- ]
|
|
|
dd68f4 |
|
|
|
dd68f4 |
+ # Add cert in two steps due to bug #1393668.
|
|
|
dd68f4 |
+
|
|
|
dd68f4 |
+ # First, import cert into HSM without trust attributes.
|
|
|
dd68f4 |
if self.token:
|
|
|
dd68f4 |
- cmd.extend(['-h', self.token])
|
|
|
dd68f4 |
+ cmd = [
|
|
|
dd68f4 |
+ 'certutil',
|
|
|
dd68f4 |
+ '-A',
|
|
|
dd68f4 |
+ '-d', self.directory,
|
|
|
dd68f4 |
+ '-h', self.token,
|
|
|
dd68f4 |
+ '-f', self.password_file,
|
|
|
dd68f4 |
+ '-n', nickname,
|
|
|
dd68f4 |
+ '-i', cert_file,
|
|
|
dd68f4 |
+ '-t', ''
|
|
|
dd68f4 |
+ ]
|
|
|
dd68f4 |
|
|
|
dd68f4 |
- cmd.extend([
|
|
|
dd68f4 |
- '-f', self.password_file,
|
|
|
dd68f4 |
+ # Ignore return code due to bug #1393668.
|
|
|
dd68f4 |
+ subprocess.call(cmd)
|
|
|
dd68f4 |
+
|
|
|
dd68f4 |
+ # Then, import cert into internal token with trust attributes.
|
|
|
dd68f4 |
+ cmd = [
|
|
|
dd68f4 |
+ 'certutil',
|
|
|
dd68f4 |
+ '-A',
|
|
|
dd68f4 |
+ '-d', self.directory,
|
|
|
dd68f4 |
+ '-f', self.internal_password_file,
|
|
|
dd68f4 |
'-n', nickname,
|
|
|
dd68f4 |
'-i', cert_file,
|
|
|
dd68f4 |
'-t', trust_attributes
|
|
|
dd68f4 |
- ])
|
|
|
dd68f4 |
+ ]
|
|
|
dd68f4 |
|
|
|
dd68f4 |
subprocess.check_call(cmd)
|
|
|
dd68f4 |
|
|
|
dd68f4 |
@@ -584,7 +613,7 @@ class NSSDatabase(object):
|
|
|
dd68f4 |
else:
|
|
|
dd68f4 |
n = '%s #%d' % (nickname, counter)
|
|
|
dd68f4 |
|
|
|
dd68f4 |
- self.add_cert(n, cert_file, trust_attributes)
|
|
|
dd68f4 |
+ self.add_cert(n, cert_file, trust_attributes=trust_attributes)
|
|
|
dd68f4 |
nicks.append(n)
|
|
|
dd68f4 |
|
|
|
dd68f4 |
counter += 1
|
|
|
dd68f4 |
diff --git a/base/server/python/pki/server/__init__.py b/base/server/python/pki/server/__init__.py
|
|
|
dd68f4 |
index 13b3258..d556312 100644
|
|
|
dd68f4 |
--- a/base/server/python/pki/server/__init__.py
|
|
|
dd68f4 |
+++ b/base/server/python/pki/server/__init__.py
|
|
|
dd68f4 |
@@ -654,7 +654,8 @@ class PKIInstance(object):
|
|
|
dd68f4 |
return pki.nssdb.NSSDatabase(
|
|
|
dd68f4 |
directory=self.nssdb_dir,
|
|
|
dd68f4 |
token=token,
|
|
|
dd68f4 |
- password=self.get_token_password(token))
|
|
|
dd68f4 |
+ password=self.get_token_password(token),
|
|
|
dd68f4 |
+ internal_password=self.get_token_password())
|
|
|
dd68f4 |
|
|
|
dd68f4 |
def external_cert_exists(self, nickname, token):
|
|
|
dd68f4 |
for cert in self.external_certs:
|
|
|
dd68f4 |
--
|
|
|
dd68f4 |
1.8.3.1
|
|
|
dd68f4 |
|
|
|
dd68f4 |
|
|
|
dd68f4 |
From de51508e2262cf98de4360c92af69249e2ef0876 Mon Sep 17 00:00:00 2001
|
|
|
dd68f4 |
From: "Endi S. Dewata" <edewata@redhat.com>
|
|
|
dd68f4 |
Date: Wed, 16 Nov 2016 03:42:49 +0100
|
|
|
dd68f4 |
Subject: [PATCH 2/2] Fixed hanging subordinate CA with HSM installation in
|
|
|
dd68f4 |
FIPS mode.
|
|
|
dd68f4 |
|
|
|
dd68f4 |
When installing subordinate CA with HSM, the installer calls the
|
|
|
dd68f4 |
pki CLI (which is implemented using JSS) to validate the imported
|
|
|
dd68f4 |
CA certificate in HSM. Normally, the HSM password is specified as
|
|
|
dd68f4 |
CLI parameter, but in FIPS mode JSS requires both the HSM and the
|
|
|
dd68f4 |
internal token passwords. Since the CLI only takes one password,
|
|
|
dd68f4 |
JSS will prompt for the missing one on the console causing the
|
|
|
dd68f4 |
installation to hang.
|
|
|
dd68f4 |
|
|
|
dd68f4 |
As a temporary solution, the pki-server subsystem-cert-validate
|
|
|
dd68f4 |
command has been modified to validate certificates stored in the
|
|
|
dd68f4 |
internal token only and it will use the internal token password,
|
|
|
dd68f4 |
so only a single password is required. Further investigation in
|
|
|
dd68f4 |
CLI/JSS/NSS is needed to support validating certificates in HSM
|
|
|
dd68f4 |
without password prompts.
|
|
|
dd68f4 |
|
|
|
dd68f4 |
https://fedorahosted.org/pki/ticket/2543
|
|
|
dd68f4 |
(cherry picked from commit 65013d222a9e612aaaaf49ee03ceed5d6c154f59)
|
|
|
dd68f4 |
(cherry picked from commit c8553a5308e23b66cee7fc1a357042f99d07b0c7)
|
|
|
dd68f4 |
---
|
|
|
dd68f4 |
base/server/python/pki/server/cli/subsystem.py | 21 ++++++++-------------
|
|
|
dd68f4 |
1 file changed, 8 insertions(+), 13 deletions(-)
|
|
|
dd68f4 |
|
|
|
dd68f4 |
diff --git a/base/server/python/pki/server/cli/subsystem.py b/base/server/python/pki/server/cli/subsystem.py
|
|
|
dd68f4 |
index 42da26e..04461f2 100644
|
|
|
dd68f4 |
--- a/base/server/python/pki/server/cli/subsystem.py
|
|
|
dd68f4 |
+++ b/base/server/python/pki/server/cli/subsystem.py
|
|
|
dd68f4 |
@@ -951,11 +951,8 @@ class SubsystemCertValidateCLI(pki.cli.CLI):
|
|
|
dd68f4 |
|
|
|
dd68f4 |
print(' Token: %s' % token)
|
|
|
dd68f4 |
|
|
|
dd68f4 |
- if token and token.lower() in ['internal', 'internal key storage token']:
|
|
|
dd68f4 |
- token = None
|
|
|
dd68f4 |
-
|
|
|
dd68f4 |
- # get token password and store in temporary file
|
|
|
dd68f4 |
- passwd = instance.get_token_password(token)
|
|
|
dd68f4 |
+ # get internal token password and store in temporary file
|
|
|
dd68f4 |
+ passwd = instance.get_token_password()
|
|
|
dd68f4 |
|
|
|
dd68f4 |
pwfile_handle, pwfile_path = mkstemp()
|
|
|
dd68f4 |
os.write(pwfile_handle, passwd)
|
|
|
dd68f4 |
@@ -964,15 +961,13 @@ class SubsystemCertValidateCLI(pki.cli.CLI):
|
|
|
dd68f4 |
try:
|
|
|
dd68f4 |
cmd = ['pki',
|
|
|
dd68f4 |
'-d', instance.nssdb_dir,
|
|
|
dd68f4 |
- '-C', pwfile_path]
|
|
|
dd68f4 |
-
|
|
|
dd68f4 |
- if token:
|
|
|
dd68f4 |
- cmd.extend(['--token', token])
|
|
|
dd68f4 |
+ '-C', pwfile_path,
|
|
|
dd68f4 |
+ 'client-cert-validate',
|
|
|
dd68f4 |
+ nickname,
|
|
|
dd68f4 |
+ '--certusage', usage]
|
|
|
dd68f4 |
|
|
|
dd68f4 |
- cmd.extend(['client-cert-validate',
|
|
|
dd68f4 |
- nickname,
|
|
|
dd68f4 |
- '--certusage', usage
|
|
|
dd68f4 |
- ])
|
|
|
dd68f4 |
+ if self.verbose:
|
|
|
dd68f4 |
+ print('Command: %s' % cmd)
|
|
|
dd68f4 |
|
|
|
dd68f4 |
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
|
|
|
dd68f4 |
print(' Status: VALID')
|
|
|
dd68f4 |
--
|
|
|
dd68f4 |
1.8.3.1
|
|
|
dd68f4 |
|