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

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