Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure KDC to use certs after they are deployed #567

Closed
wants to merge 1 commit into from

Conversation

simo5
Copy link
Contributor

@simo5 simo5 commented Mar 9, 2017

Certmonger needs to access the KDC when it tries to obtain certs,
so make sure the KDC can run, then reconfigure it to use pkinit anchors
once certs are deployed.

@simo5
Copy link
Contributor Author

simo5 commented Mar 9, 2017

Still testing but this should be the way to go to fix the bug reported in #564

self.__template_file(paths.KRB5KDC_KDC_CONF, chmod=None, backup=False)
try:
self.stop()
self.start()
Copy link
Contributor

@martbab martbab Mar 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use self.restart here?

self.stop()
self.start()
except Exception:
root_logger.critical("krb5kdc service failed to restart")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is critical error, please re-raise to stop installation altogether. If it is a soft error, please log at error level not critical.

@martbab
Copy link
Contributor

martbab commented Mar 10, 2017

I think we can avoid the copy-pasta by actually moving PKINIT requesting code into __common_post_setup like this:

diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py
index 79803ca..725d36c 100644
--- a/ipaserver/install/krbinstance.py
+++ b/ipaserver/install/krbinstance.py
@@ -138,10 +138,14 @@ class KrbInstance(service.Service):
             # It could have been not running
             pass
 
-    def __common_post_setup(self):
+    def __common_post_setup(self, setup_pkinit):
         self.step("starting the KDC", self.__start_instance)
         self.step("configuring KDC to start on boot", self.__enable)
 
+        if setup_pkinit:
+            self.step("installing X509 Certificate for PKINIT",
+                      self.setup_pkinit)
+
     def create_instance(self, realm_name, host_name, domain_name, admin_password, master_password, setup_pkinit=False, pkcs12_info=None, subject_base=None):
         self.master_password = master_password
         self.pkcs12_info = pkcs12_info
@@ -158,11 +162,7 @@ class KrbInstance(service.Service):
         self.step("adding the password extension to the directory", self.__add_pwd_extop_module)
         self.step("creating anonymous principal", self.add_anonymous_principal)
 
-        self.__common_post_setup()
-
-        if setup_pkinit:
-            self.step("installing X509 Certificate for PKINIT",
-                      self.setup_pkinit)
+        self.__common_post_setup(setup_pkinit)
 
         self.start_creation(runtime=30)
 
@@ -183,11 +183,8 @@ class KrbInstance(service.Service):
 
         self.step("configuring KDC", self.__configure_instance)
         self.step("adding the password extension to the directory", self.__add_pwd_extop_module)
-        if setup_pkinit:
-            self.step("installing X509 Certificate for PKINIT",
-                      self.setup_pkinit)
 
-        self.__common_post_setup()
+        self.__common_post_setup(setup_pkinit)
 
         self.start_creation(runtime=30)
 

Also I have some inline comments.

Certmonger needs to access the KDC when it tries to obtain certs,
so make sure the KDC can run, then reconfigure it to use pkinit anchors
once certs are deployed.

Signed-off-by: Simo Sorce <simo@redhat.com>
@simo5
Copy link
Contributor Author

simo5 commented Mar 10, 2017

Should have addressed all concerns in this push

@martbab
Copy link
Contributor

martbab commented Mar 13, 2017

Codewise LGTM, but I get the following error on the replica being deployed regardless of whether I use --setup-ca or not. WebUI on replica is not working and throwing around auth erros:

Request ID '20170313152814':
        status: CA_REJECTED
        ca-error: Server at https://replica1.ipa.test/ipa/xml failed request, will retry: -504 (libcurl failed to execute the HTTP POST transaction, explaining:  Failed to connect to replica1.ipa.test port 443: Connection refused).
        stuck: yes
        key pair storage: type=FILE,location='/var/kerberos/krb5kdc/kdc.key'
        certificate: type=FILE,location='/var/kerberos/krb5kdc/kdc.crt'
        CA: IPA
        issuer: 
        subject: 
        expires: unknown
        pre-save command: 
        post-save command: 
        track: yes
        auto-renew: yes

If I resubmit the request it goes to 'MONITORING' status. Whn I restart KDC I can use replica's WebUI again. I guess the problem is that certmonger contacts replica's own CA even if it is not configured and apache is not running yet, hence the error. It should contact remote master at all times.

@martbab
Copy link
Contributor

martbab commented Mar 14, 2017

@simo5 actually I found multiple issues during review and concluded that setting up PKINIT on DL1 replica never worked correctly actually. Will open respective blocker tickets ASAP.

@simo5
Copy link
Contributor Author

simo5 commented Mar 14, 2017

Can you figure out exactly why certmonger is doing this ?

@martbab
Copy link
Contributor

martbab commented Mar 14, 2017

@simo5 yes the whole PKINIT setup logic on replica is flawed and will probably need to be moved into a later point in master/replica install. Can I re-use your PR and prepare a new one that will fix it properly? I will keep you the author of this commit if you wish.

@simo5
Copy link
Contributor Author

simo5 commented Mar 14, 2017

Sure no prob

@martbab
Copy link
Contributor

martbab commented Mar 14, 2017

@simo5 thank you

@martbab
Copy link
Contributor

martbab commented Mar 15, 2017

Superseded by #584

@martbab martbab closed this Mar 15, 2017
@martbab martbab added the rejected Pull Request has been rejected label Mar 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rejected Pull Request has been rejected
Projects
None yet
2 participants