483b06
From f57c0fbd46d0cca82b45c2f16fab316aa2554a08 Mon Sep 17 00:00:00 2001
483b06
From: Stanislav Laznicka <slaznick@redhat.com>
483b06
Date: Fri, 24 Mar 2017 09:52:18 +0100
483b06
Subject: [PATCH] Get correct CA cert nickname in CA-less
483b06
483b06
During CA-less installation, we initialize the HTTPD alias
483b06
database from a pkcs12 file. This means there's going to
483b06
be different nicknames to the added certificates. Store
483b06
the CA certificate nickname in HTTPInstance__setup_ssl()
483b06
to be able to correctly export it later.
483b06
483b06
https://pagure.io/freeipa/issue/6806
483b06
483b06
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
483b06
---
483b06
 ipaserver/install/httpinstance.py | 7 ++++++-
483b06
 1 file changed, 6 insertions(+), 1 deletion(-)
483b06
483b06
diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py
483b06
index 01b55e7a7b00d020b7745c419267ad4f0ba86804..3e4252cb1e907618d4aa15f7381caff5e4e868e3 100644
483b06
--- a/ipaserver/install/httpinstance.py
483b06
+++ b/ipaserver/install/httpinstance.py
483b06
@@ -118,6 +118,7 @@ class WebGuiInstance(service.SimpleServiceInstance):
483b06
     def __init__(self):
483b06
         service.SimpleServiceInstance.__init__(self, "ipa_webgui")
483b06
 
483b06
+
483b06
 class HTTPInstance(service.Service):
483b06
     def __init__(self, fstore=None, cert_nickname='Server-Cert',
483b06
                  api=api):
483b06
@@ -130,6 +131,7 @@ class HTTPInstance(service.Service):
483b06
             service_user=HTTPD_USER,
483b06
             keytab=paths.HTTP_KEYTAB)
483b06
 
483b06
+        self.cacert_nickname = None
483b06
         self.cert_nickname = cert_nickname
483b06
         self.ca_is_configured = True
483b06
         self.keytab_user = constants.GSSPROXY_USER
483b06
@@ -441,6 +443,9 @@ class HTTPInstance(service.Service):
483b06
             if not server_certs:
483b06
                 raise RuntimeError("Could not find a suitable server cert.")
483b06
 
483b06
+        # store the CA cert nickname so that we can publish it later on
483b06
+        self.cacert_nickname = db.cacert_name
483b06
+
483b06
     def __import_ca_certs(self):
483b06
         db = certs.CertDB(self.realm, nssdir=paths.HTTPD_ALIAS_DIR,
483b06
                           subject_base=self.subject_base)
483b06
@@ -449,7 +454,7 @@ class HTTPInstance(service.Service):
483b06
     def __publish_ca_cert(self):
483b06
         ca_db = certs.CertDB(self.realm, nssdir=paths.HTTPD_ALIAS_DIR,
483b06
                              subject_base=self.subject_base)
483b06
-        ca_db.publish_ca_cert(paths.CA_CRT)
483b06
+        ca_db.export_pem_cert(self.cacert_nickname, paths.CA_CRT)
483b06
 
483b06
     def is_kdcproxy_configured(self):
483b06
         """Check if KDC proxy has already been configured in the past"""
483b06
-- 
483b06
2.12.2
483b06