483b06
From 036605789d6b34f5592d2ef38723eeb87e6ae21a Mon Sep 17 00:00:00 2001
483b06
From: Stanislav Laznicka <slaznick@redhat.com>
483b06
Date: Tue, 28 Mar 2017 13:54:16 +0200
483b06
Subject: [PATCH] Generate PIN for PKI to help Dogtag in FIPS
483b06
483b06
Dogtag is currently unable to generate a PIN it could use for
483b06
an NSS database creation in FIPS. Generate it for them so that
483b06
we don't fail.
483b06
483b06
https://pagure.io/freeipa/issue/6824
483b06
483b06
Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
483b06
---
483b06
 ipaserver/install/cainstance.py  | 6 +++++-
483b06
 ipaserver/install/krainstance.py | 6 +++++-
483b06
 2 files changed, 10 insertions(+), 2 deletions(-)
483b06
483b06
diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py
483b06
index f0d3c236810d01f08192b239c0edb362ed78e071..92bb760d39d23fedb40b7e3c5bea53381f1c87ad 100644
483b06
--- a/ipaserver/install/cainstance.py
483b06
+++ b/ipaserver/install/cainstance.py
483b06
@@ -541,6 +541,10 @@ class CAInstance(DogtagInstance):
483b06
         # CA key algorithm
483b06
         config.set("CA", "pki_ca_signing_key_algorithm", self.ca_signing_algorithm)
483b06
 
483b06
+        # generate pin which we know can be used for FIPS NSS database
483b06
+        pki_pin = ipautil.ipa_generate_password()
483b06
+        config.set("CA", "pki_pin", pki_pin)
483b06
+
483b06
         if self.clone:
483b06
 
483b06
             if self.no_db_setup:
483b06
@@ -613,7 +617,7 @@ class CAInstance(DogtagInstance):
483b06
         try:
483b06
             DogtagInstance.spawn_instance(
483b06
                 self, cfg_file,
483b06
-                nolog_list=(self.dm_password, self.admin_password)
483b06
+                nolog_list=(self.dm_password, self.admin_password, pki_pin)
483b06
             )
483b06
         finally:
483b06
             os.remove(cfg_file)
483b06
diff --git a/ipaserver/install/krainstance.py b/ipaserver/install/krainstance.py
483b06
index b41ccb6fa6517f53ad1f83389b45795f0cd135bc..34d667857a8055752e258a591af983190f33daa5 100644
483b06
--- a/ipaserver/install/krainstance.py
483b06
+++ b/ipaserver/install/krainstance.py
483b06
@@ -235,6 +235,10 @@ class KRAInstance(DogtagInstance):
483b06
             "KRA", "pki_share_dbuser_dn",
483b06
             str(DN(('uid', 'pkidbuser'), ('ou', 'people'), ('o', 'ipaca'))))
483b06
 
483b06
+        # generate pin which we know can be used for FIPS NSS database
483b06
+        pki_pin = ipautil.ipa_generate_password()
483b06
+        config.set("KRA", "pki_pin", pki_pin)
483b06
+
483b06
         _p12_tmpfile_handle, p12_tmpfile_name = tempfile.mkstemp(dir=paths.TMP)
483b06
 
483b06
         if self.clone:
483b06
@@ -275,7 +279,7 @@ class KRAInstance(DogtagInstance):
483b06
         try:
483b06
             DogtagInstance.spawn_instance(
483b06
                 self, cfg_file,
483b06
-                nolog_list=(self.dm_password, self.admin_password)
483b06
+                nolog_list=(self.dm_password, self.admin_password, pki_pin)
483b06
             )
483b06
         finally:
483b06
             os.remove(p12_tmpfile_name)
483b06
-- 
483b06
2.12.1
483b06