Blame SOURCES/0007-Specify-cert_paths-when-calling-PKIConnection_rhbz#1849155.patch

91acb2
From 9ded9e2573a00c388533f2a09365c499a4e2961e Mon Sep 17 00:00:00 2001
91acb2
From: Alexander Scheel <ascheel@redhat.com>
91acb2
Date: Fri, 19 Jun 2020 08:48:56 -0400
91acb2
Subject: [PATCH] Specify cert_paths when calling PKIConnection
91acb2
91acb2
PKIConnection now defaults to specifying verify=True. We've introduced
91acb2
a new parameter, cert_paths, to specify additional paths (directories or
91acb2
files) to load as certificates. Specify the IPA CA certificate file so
91acb2
we can guarantee connections succeed and validate the peer's certificate.
91acb2
91acb2
Point to IPA CA certificate during pkispawn
91acb2
91acb2
Bump pki_version to 10.9.0-0.4 (aka -b2)
91acb2
91acb2
Fixes: https://pagure.io/freeipa/issue/8379
91acb2
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1849155
91acb2
Related: https://github.com/dogtagpki/pki/pull/443
91acb2
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1426572
91acb2
Signed-off-by: Alexander Scheel <ascheel@redhat.com>
91acb2
Signed-off-by: Christian Heimes <cheimes@redhat.com>
91acb2
Reviewed-By: Christian Heimes <cheimes@redhat.com>
91acb2
---
91acb2
 freeipa.spec.in                       |  6 +++---
91acb2
 install/tools/ipa-pki-wait-running.in |  3 ++-
91acb2
 ipaserver/install/cainstance.py       |  7 +++++++
91acb2
 ipaserver/install/dogtaginstance.py   |  3 ++-
91acb2
 ipaserver/plugins/dogtag.py           | 11 +++++------
91acb2
 5 files changed, 19 insertions(+), 11 deletions(-)
91acb2
91acb2
diff --git a/freeipa.spec.in b/freeipa.spec.in
91acb2
index 74e752ea5..d00b9d640 100755
91acb2
--- a/freeipa.spec.in
91acb2
+++ b/freeipa.spec.in
91acb2
@@ -112,9 +112,9 @@
91acb2
 # Fedora
91acb2
 %endif
91acb2
 
91acb2
-# 10.7.3 supports LWCA key replication using AES
91acb2
-# https://pagure.io/freeipa/issue/8020
91acb2
-%global pki_version 10.7.3-1
91acb2
+# PKIConnection has been modified to always validate certs.
91acb2
+# https://pagure.io/freeipa/issue/8379
91acb2
+%global pki_version 10.9.0-0.4
91acb2
 
91acb2
 # https://pagure.io/certmonger/issue/90
91acb2
 %global certmonger_version 0.79.7-1
91acb2
diff --git a/install/tools/ipa-pki-wait-running.in b/install/tools/ipa-pki-wait-running.in
91acb2
index 69f5ec296..4f0f2f34a 100644
91acb2
--- a/install/tools/ipa-pki-wait-running.in
91acb2
+++ b/install/tools/ipa-pki-wait-running.in
91acb2
@@ -59,7 +59,8 @@ def get_conn(hostname, subsystem):
91acb2
     """
91acb2
     conn = PKIConnection(
91acb2
         hostname=hostname,
91acb2
-        subsystem=subsystem
91acb2
+        subsystem=subsystem,
91acb2
+        cert_paths=paths.IPA_CA_CRT
91acb2
     )
91acb2
     logger.info(
91acb2
         "Created connection %s://%s:%s/%s",
91acb2
diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py
91acb2
index 706bc28cc..9294f1dba 100644
91acb2
--- a/ipaserver/install/cainstance.py
91acb2
+++ b/ipaserver/install/cainstance.py
91acb2
@@ -509,6 +509,13 @@ class CAInstance(DogtagInstance):
91acb2
         else:
91acb2
             pki_pin = None
91acb2
 
91acb2
+        # When spawning a CA instance, always point to IPA_CA_CRT if it
91acb2
+        # exists. Later, when we're performing step 2 of an external CA
91acb2
+        # installation, we'll overwrite this key to point to the real
91acb2
+        # external CA.
91acb2
+        if os.path.exists(paths.IPA_CA_CRT):
91acb2
+            cfg['pki_cert_chain_path'] = paths.IPA_CA_CRT
91acb2
+
91acb2
         if self.clone:
91acb2
             if self.no_db_setup:
91acb2
                 cfg.update(
91acb2
diff --git a/ipaserver/install/dogtaginstance.py b/ipaserver/install/dogtaginstance.py
91acb2
index 361d80a8c..7e295665c 100644
91acb2
--- a/ipaserver/install/dogtaginstance.py
91acb2
+++ b/ipaserver/install/dogtaginstance.py
91acb2
@@ -70,7 +70,8 @@ def get_security_domain():
91acb2
     connection = PKIConnection(
91acb2
         protocol='https',
91acb2
         hostname=api.env.ca_host,
91acb2
-        port='8443'
91acb2
+        port='8443',
91acb2
+        cert_paths=paths.IPA_CA_CRT
91acb2
     )
91acb2
     domain_client = pki.system.SecurityDomainClient(connection)
91acb2
     info = domain_client.get_security_domain_info()
91acb2
diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py
91acb2
index 4de26d76f..b300f6b18 100644
91acb2
--- a/ipaserver/plugins/dogtag.py
91acb2
+++ b/ipaserver/plugins/dogtag.py
91acb2
@@ -2082,13 +2082,12 @@ class kra(Backend):
91acb2
             'https',
91acb2
             self.kra_host,
91acb2
             str(self.kra_port),
91acb2
-            'kra')
91acb2
+            'kra',
91acb2
+            cert_paths=paths.IPA_CA_CRT
91acb2
+        )
91acb2
 
91acb2
-        connection.session.cert = (paths.RA_AGENT_PEM, paths.RA_AGENT_KEY)
91acb2
-        # uncomment the following when this commit makes it to release
91acb2
-        # https://git.fedorahosted.org/cgit/pki.git/commit/?id=71ae20c
91acb2
-        # connection.set_authentication_cert(paths.RA_AGENT_PEM,
91acb2
-        #                                    paths.RA_AGENT_KEY)
91acb2
+        connection.set_authentication_cert(paths.RA_AGENT_PEM,
91acb2
+                                           paths.RA_AGENT_KEY)
91acb2
 
91acb2
         try:
91acb2
             yield KRAClient(connection, crypto)
91acb2
-- 
91acb2
2.26.2
91acb2