483b06
From 4a9ff573f1c9c91e1e2e1e2d7de70951b7333fb4 Mon Sep 17 00:00:00 2001
483b06
From: Martin Babinsky <mbabinsk@redhat.com>
483b06
Date: Fri, 23 Jun 2017 15:47:48 +0200
483b06
Subject: [PATCH] smart card advise: use password when changing trust flags on
483b06
 HTTP cert
483b06
483b06
This is to prevent NSS asking for database password when operating in
483b06
FIPS 140 mode.
483b06
483b06
https://pagure.io/freeipa/issue/7036
483b06
483b06
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
483b06
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
483b06
---
483b06
 ipaserver/advise/plugins/smart_card_auth.py | 9 +++++++--
483b06
 1 file changed, 7 insertions(+), 2 deletions(-)
483b06
483b06
diff --git a/ipaserver/advise/plugins/smart_card_auth.py b/ipaserver/advise/plugins/smart_card_auth.py
483b06
index 3ff94be1e8b108668989602b1b406a39d23ff501..5134db535e8f10e8cf850dbf0696b679aacec4f5 100644
483b06
--- a/ipaserver/advise/plugins/smart_card_auth.py
483b06
+++ b/ipaserver/advise/plugins/smart_card_auth.py
483b06
@@ -2,6 +2,8 @@
483b06
 # Copyright (C) 2017 FreeIPA Contributors see COPYING for license
483b06
 #
483b06
 
483b06
+import os
483b06
+
483b06
 from ipalib.plugable import Registry
483b06
 from ipaplatform import services
483b06
 from ipaplatform.paths import paths
483b06
@@ -172,6 +174,8 @@ class config_server_for_smart_card_auth(common_smart_card_auth_config):
483b06
         return fmt_line.format(directive=directive, filename=filename)
483b06
 
483b06
     def mark_httpd_cert_as_trusted(self):
483b06
+        httpd_nss_database_pwd_file = os.path.join(
483b06
+            paths.HTTPD_ALIAS_DIR, 'pwdfile.txt')
483b06
         self.log.comment(
483b06
             'mark the HTTP certificate as trusted peer to avoid '
483b06
             'chicken-egg startup issue')
483b06
@@ -181,8 +185,9 @@ class config_server_for_smart_card_auth(common_smart_card_auth_config):
483b06
                 " cut -f 2 -d ' ')"))
483b06
 
483b06
         self.log.exit_on_failed_command(
483b06
-            'certutil -M -n $http_cert_nick -d "{}" -t "Pu,u,u"'.format(
483b06
-                paths.HTTPD_ALIAS_DIR),
483b06
+            'certutil -M -n $http_cert_nick -d "{}" -f {} -t "Pu,u,u"'.format(
483b06
+                paths.HTTPD_ALIAS_DIR,
483b06
+                httpd_nss_database_pwd_file),
483b06
             ['Can not set trust flags on HTTP certificate'])
483b06
 
483b06
     def _interpolate_nssnickname_directive_file_into_command(self, fmt_line):
483b06
-- 
483b06
2.9.4
483b06