From 6886b5f88b11e6de9eaaba7e64867c150328f98d Mon Sep 17 00:00:00 2001
From: Michael Fürmann <michael@spicyweb.de>
Date: Tue, 03 Mar 2015 13:24:24 -0500
Subject: [PATCH] closes #4 certificate creation during installation

---
 install/lib/installer_base.lib.php |   43 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index acaaf3b..8fd1862 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -1349,6 +1349,30 @@
         $content = str_replace('{server_id}', $conf['server_id'], $content);
         wf($full_file_name, $content);
 
+        // Create SSL Certificate for localhost
+        echo "writing new private key to 'localhost.key'\n-----\n";
+        $ssl_country = $this->free_query('Country Name (2 letter code)', 'AU');
+        $ssl_locality = $this->free_query('Locality Name (eg, city)', '');
+        $ssl_organisation = $this->free_query('Organization Name (eg, company)', 'Internet Widgits Pty Ltd');
+        $ssl_organisation_unit = $this->free_query('Organizational Unit Name (eg, section)', '');
+        $ssl_domain = $this->free_query('Common Name (e.g. server FQDN or YOUR name)', $conf['hostname']);
+        $ssl_email = $this->free_query('Email Address', '');
+
+        $tpl = new tpl('metronome_conf_ssl.master');
+        $tpl->setVar('ssl_country',$ssl_country);
+        $tpl->setVar('ssl_locality',$ssl_locality);
+        $tpl->setVar('ssl_organisation',$ssl_organisation);
+        $tpl->setVar('ssl_organisation_unit',$ssl_organisation_unit);
+        $tpl->setVar('domain',$ssl_domain);
+        $tpl->setVar('ssl_email',$ssl_email);
+        wf('/etc/metronome/certs/localhost.cnf', $tpl->grab());
+        unset($tpl);
+        // Generate new key, csr and cert
+        exec("(cd /etc/metronome/certs && make localhost.key)");
+        exec("(cd /etc/metronome/certs && make localhost.csr)");
+        exec("(cd /etc/metronome/certs && make localhost.cert)");
+        exec('chmod 0400 /etc/metronome/certs/localhost.key');
+        exec('chown metronome /etc/metronome/certs/localhost.key');
 
         // Copy init script
         caselog('cp -f apps/metronome-init /etc/init.d/metronome', __FILE__, __LINE__);
@@ -1356,7 +1380,24 @@
 
         exec($this->getinitcommand('xmpp', 'restart'));
 
-
+/*
+writing new private key to 'smtpd.key'
+-----
+You are about to be asked to enter information that will be incorporated
+into your certificate request.
+What you are about to enter is what is called a Distinguished Name or a DN.
+There are quite a few fields but you can leave some blank
+For some fields there will be a default value,
+If you enter '.', the field will be left blank.
+-----
+Country Name (2 letter code) [AU]:
+State or Province Name (full name) [Some-State]:
+Locality Name (eg, city) []:
+Organization Name (eg, company) [Internet Widgits Pty Ltd]:
+Organizational Unit Name (eg, section) []:
+Common Name (e.g. server FQDN or YOUR name) []:
+Email Address []:
+ * */
 
         /*// Dont just copy over the virtualhost template but add some custom settings
         $tpl = new tpl('apache_apps.vhost.master');

--
Gitblit v1.9.1