483b06
From ceb0d5c2a4a8e8fae271e5a37ee32f58a2d36273 Mon Sep 17 00:00:00 2001
483b06
From: Florence Blanc-Renaud <flo@redhat.com>
483b06
Date: Tue, 16 May 2017 17:24:09 +0200
483b06
Subject: [PATCH] ipa-ca-install: append CA cert chain into /etc/ipa/ca.crt
483b06
483b06
ipa-ca-install currently overwrites /etc/ipa/ca.crt with the CA chain
483b06
retrieved from Dogtag. It should instead append the new certs, otherwise
483b06
the CA that signed dirsrv and httpd certificates is removed and ipa tools
483b06
fail.
483b06
A consequence is that ipa-kra-install fails.
483b06
This is a regression introduced by 5ab85b36.
483b06
483b06
https://pagure.io/freeipa/issue/6925
483b06
483b06
Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
483b06
---
483b06
 ipaserver/install/cainstance.py | 8 ++++++++
483b06
 1 file changed, 8 insertions(+)
483b06
483b06
diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py
483b06
index b8c8cc4fc4532fc2c911ec174d363f8280ce863b..b0e9e8757ec3e3c0d03ed930743ef5a1253b864a 100644
483b06
--- a/ipaserver/install/cainstance.py
483b06
+++ b/ipaserver/install/cainstance.py
483b06
@@ -793,6 +793,14 @@ class CAInstance(DogtagInstance):
483b06
         # Get list of PEM certificates
483b06
         certlist = x509.pkcs7_to_pems(data, x509.DER)
483b06
 
483b06
+        # We need to append the certs to the existing file, so start by
483b06
+        # reading the file
483b06
+        if ipautil.file_exists(paths.IPA_CA_CRT):
483b06
+            ca_certs = x509.load_certificate_list_from_file(paths.IPA_CA_CRT)
483b06
+            ca_certs = [cert.public_bytes(serialization.Encoding.PEM)
483b06
+                        for cert in ca_certs]
483b06
+            certlist.extend(ca_certs)
483b06
+
483b06
         # We have all the certificates in certlist, write them to a PEM file
483b06
         for path in [paths.IPA_CA_CRT,
483b06
                      paths.KDC_CA_BUNDLE_PEM,
483b06
-- 
483b06
2.9.4
483b06