summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/httpinstance.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2009-09-10 16:15:14 -0400
committerRob Crittenden <rcritten@redhat.com>2009-09-15 10:01:08 -0400
commit49b36583a50e7f542e0667f3e2432ab1aa63924e (patch)
tree1c11b906018784db6e9415c17f116db4a1fd49e0 /ipaserver/install/httpinstance.py
parentbb09db2228694cd78b5e4e281109e55df9de97be (diff)
downloadfreeipa-49b36583a50e7f542e0667f3e2432ab1aa63924e.zip
freeipa-49b36583a50e7f542e0667f3e2432ab1aa63924e.tar.gz
freeipa-49b36583a50e7f542e0667f3e2432ab1aa63924e.tar.xz
Add external CA signing and abstract out the RA backend
External CA signing is a 2-step process. You first have to run the IPA installer which will generate a CSR. You pass this CSR to your external CA and get back a cert. You then pass this cert and the CA cert and re-run the installer. The CSR is always written to /root/ipa.csr. A run would look like: # ipa-server-install --ca --external-ca -p password -a password -r EXAMPLE.COM -u dirsrv -n example.com --hostname=ipa.example.com -U [ sign cert request ] # ipa-server-install --ca --external-ca -p password -a password --external_cert_file=/tmp/rob.crt --external_ca_file=/tmp/cacert.crt -U -p password -a password -r EXAMPLE.COM -u dirsrv -n example.com --hostname=ipa.example.com This also abstracts out the RA backend plugin so the self-signed CA we create can be used in a running server. This means that the cert plugin can request certs (and nothing else). This should let us do online replica creation. To handle the self-signed CA the simple ca_serialno file now contains additional data so we don't have overlapping serial numbers in replicas. This isn't used yet. Currently the cert plugin will not work on self-signed replicas. One very important change for self-signed CAs is that the CA is no longer held in the DS database. It is now in the Apache database. Lots of general fixes were also made in ipaserver.install.certs including: - better handling when multiple CA certificates are in a single file - A temporary directory for request certs is not always created when the class is instantiated (you have to call setup_cert_request())
Diffstat (limited to 'ipaserver/install/httpinstance.py')
-rw-r--r--ipaserver/install/httpinstance.py36
1 files changed, 25 insertions, 11 deletions
diff --git a/ipaserver/install/httpinstance.py b/ipaserver/install/httpinstance.py
index b6483fb..7e7adfa 100644
--- a/ipaserver/install/httpinstance.py
+++ b/ipaserver/install/httpinstance.py
@@ -65,8 +65,7 @@ class HTTPInstance(service.Service):
self.step("disabling mod_ssl in httpd", self.__disable_mod_ssl)
self.step("Setting mod_nss port to 443", self.__set_mod_nss_port)
- if not self_signed_ca:
- self.step("Setting mod_nss password file", self.__set_mod_nss_passwordfile)
+ self.step("Setting mod_nss password file", self.__set_mod_nss_passwordfile)
self.step("Adding URL rewriting rules", self.__add_include)
self.step("configuring httpd", self.__configure_http)
self.step("creating a keytab for httpd", self.__create_http_keytab)
@@ -158,7 +157,7 @@ class HTTPInstance(service.Service):
def __setup_ssl(self):
if self.self_signed_ca:
- ca_db = certs.CertDB(dsinstance.config_dirname(dsinstance.realm_to_serverid(self.realm)))
+ ca_db = certs.CertDB(NSS_DIR)
else:
ca_db = certs.CertDB(NSS_DIR, host_name=self.fqdn)
db = certs.CertDB(NSS_DIR)
@@ -176,6 +175,7 @@ class HTTPInstance(service.Service):
else:
if self.self_signed_ca:
db.create_from_cacert(ca_db.cacert_fname)
+ db.create_password_conf()
db.create_server_cert("Server-Cert", self.fqdn, ca_db)
db.create_signing_cert("Signing-Cert", "Object Signing Cert", ca_db)
else:
@@ -184,14 +184,27 @@ class HTTPInstance(service.Service):
db.create_password_conf()
# Fix the database permissions
- os.chmod(NSS_DIR + "/cert8.db", 0640)
- os.chmod(NSS_DIR + "/key3.db", 0640)
- os.chmod(NSS_DIR + "/secmod.db", 0640)
+ os.chmod(NSS_DIR + "/cert8.db", 0660)
+ os.chmod(NSS_DIR + "/key3.db", 0660)
+ os.chmod(NSS_DIR + "/secmod.db", 0660)
+ os.chmod(NSS_DIR + "/pwdfile.txt", 0660)
pent = pwd.getpwnam("apache")
os.chown(NSS_DIR + "/cert8.db", 0, pent.pw_gid )
os.chown(NSS_DIR + "/key3.db", 0, pent.pw_gid )
os.chown(NSS_DIR + "/secmod.db", 0, pent.pw_gid )
+ os.chown(NSS_DIR + "/pwdfile.txt", 0, pent.pw_gid )
+
+ # Fix SELinux permissions on the database
+ ipautil.run(["/sbin/restorecon", NSS_DIR + "/cert8.db"])
+ ipautil.run(["/sbin/restorecon", NSS_DIR + "/key3.db"])
+
+ # In case this got generated as part of the install, reset the
+ # context
+ if ipautil.file_exists(certs.CA_SERIALNO):
+ ipautil.run(["/sbin/restorecon", certs.CA_SERIALNO])
+ os.chown(certs.CA_SERIALNO, 0, pent.pw_gid)
+ os.chmod(certs.CA_SERIALNO, 0664)
def __setup_autoconfig(self):
prefs_txt = ipautil.template_file(ipautil.SHARE_DIR + "preferences.html.template", self.sub_dict)
@@ -202,19 +215,20 @@ class HTTPInstance(service.Service):
# The signing cert is generated in __setup_ssl
db = certs.CertDB(NSS_DIR)
+ pwdfile = open(db.passwd_fname)
+ pwd = pwdfile.read()
+ pwdfile.close()
+
tmpdir = tempfile.mkdtemp(prefix = "tmp-")
shutil.copy("/usr/share/ipa/html/preferences.html", tmpdir)
db.run_signtool(["-k", "Signing-Cert",
"-Z", "/usr/share/ipa/html/configure.jar",
- "-e", ".html",
+ "-e", ".html", "-p", pwd,
tmpdir])
shutil.rmtree(tmpdir)
def __publish_ca_cert(self):
- if self.self_signed_ca:
- ca_db = certs.CertDB(dsinstance.config_dirname(dsinstance.realm_to_serverid(self.realm)))
- else:
- ca_db = certs.CertDB(NSS_DIR)
+ ca_db = certs.CertDB(NSS_DIR)
shutil.copy(ca_db.cacert_fname, "/usr/share/ipa/html/ca.crt")
os.chmod("/usr/share/ipa/html/ca.crt", 0444)