483b06
From 82e860ae81b9e34fc6a326be4183f37a21ac1564 Mon Sep 17 00:00:00 2001
483b06
From: Simo Sorce <simo@redhat.com>
483b06
Date: Fri, 23 Jun 2017 04:48:41 -0400
483b06
Subject: [PATCH] Always check peer has keys before connecting
483b06
483b06
When pulling the DM password we may have the same issues reported in
483b06
ticket #6838 for CA keys.
483b06
This commit makes sure we always check the peer has keys before any
483b06
client operation.
483b06
483b06
Ticket #6838
483b06
483b06
Signed-off-by: Simo Sorce <simo@redhat.com>
483b06
Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
483b06
Reviewed-By: Michal Reznik <mreznik@redhat.com>
483b06
---
483b06
 ipaserver/install/custodiainstance.py | 20 ++++++++------------
483b06
 1 file changed, 8 insertions(+), 12 deletions(-)
483b06
483b06
diff --git a/ipaserver/install/custodiainstance.py b/ipaserver/install/custodiainstance.py
483b06
index 390576bc0c0edfb7d8f8895eca9df30079526aa8..bc3cea7063dff183c85b4f6e8ced7567f691001d 100644
483b06
--- a/ipaserver/install/custodiainstance.py
483b06
+++ b/ipaserver/install/custodiainstance.py
483b06
@@ -13,7 +13,6 @@ from ipaserver.install import ldapupdate
483b06
 from ipaserver.install import sysupgrade
483b06
 from base64 import b64decode
483b06
 from jwcrypto.common import json_decode
483b06
-import functools
483b06
 import shutil
483b06
 import os
483b06
 import stat
483b06
@@ -31,13 +30,6 @@ class CustodiaInstance(SimpleServiceInstance):
483b06
         self.ldap_uri = None
483b06
         self.fqdn = host_name
483b06
         self.realm = realm
483b06
-        self.__CustodiaClient = functools.partial(
483b06
-            CustodiaClient,
483b06
-            client_service='host@%s' % self.fqdn,
483b06
-            keyfile=self.server_keys,
483b06
-            keytab=paths.KRB5_KEYTAB,
483b06
-            realm=realm,
483b06
-        )
483b06
483b06
     def __config_file(self):
483b06
         template_file = os.path.basename(self.config_file) + '.template'
483b06
@@ -144,6 +136,14 @@ class CustodiaInstance(SimpleServiceInstance):
483b06
                     raise RuntimeError("Timed out trying to obtain keys.")
483b06
                 time.sleep(1)
483b06
483b06
+    def __CustodiaClient(self, server):
483b06
+        # Before we attempt to fetch keys from this host, make sure our public
483b06
+        # keys have been replicated there.
483b06
+        self.__wait_keys(server)
483b06
+
483b06
+        return CustodiaClient('host@%s' % self.fqdn, self.server_keys,
483b06
+                              paths.KRB5_KEYTAB, server, realm=self.realm)
483b06
+
483b06
     def __get_keys(self, ca_host, cacerts_file, cacerts_pwd, data):
483b06
         # Fecth all needed certs one by one, then combine them in a single
483b06
         # p12 file
483b06
@@ -151,10 +151,6 @@ class CustodiaInstance(SimpleServiceInstance):
483b06
         prefix = data['prefix']
483b06
         certlist = data['list']
483b06
483b06
-        # Before we attempt to fetch keys from this host, make sure our public
483b06
-        # keys have been replicated there.
483b06
-        self.__wait_keys(ca_host)
483b06
-
483b06
         cli = self.__CustodiaClient(server=ca_host)
483b06
483b06
         # Temporary nssdb
483b06
--
483b06
2.13.5