Skip to content

Commit 6886b5f

Browse files
committed
closes #4 certificate creation during installation
1 parent f52de04 commit 6886b5f

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed

install/lib/installer_base.lib.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,14 +1349,55 @@ public function configure_xmpp() {
13491349
$content = str_replace('{server_id}', $conf['server_id'], $content);
13501350
wf($full_file_name, $content);
13511351

1352+
// Create SSL Certificate for localhost
1353+
echo "writing new private key to 'localhost.key'\n-----\n";
1354+
$ssl_country = $this->free_query('Country Name (2 letter code)', 'AU');
1355+
$ssl_locality = $this->free_query('Locality Name (eg, city)', '');
1356+
$ssl_organisation = $this->free_query('Organization Name (eg, company)', 'Internet Widgits Pty Ltd');
1357+
$ssl_organisation_unit = $this->free_query('Organizational Unit Name (eg, section)', '');
1358+
$ssl_domain = $this->free_query('Common Name (e.g. server FQDN or YOUR name)', $conf['hostname']);
1359+
$ssl_email = $this->free_query('Email Address', '');
1360+
1361+
$tpl = new tpl('metronome_conf_ssl.master');
1362+
$tpl->setVar('ssl_country',$ssl_country);
1363+
$tpl->setVar('ssl_locality',$ssl_locality);
1364+
$tpl->setVar('ssl_organisation',$ssl_organisation);
1365+
$tpl->setVar('ssl_organisation_unit',$ssl_organisation_unit);
1366+
$tpl->setVar('domain',$ssl_domain);
1367+
$tpl->setVar('ssl_email',$ssl_email);
1368+
wf('/etc/metronome/certs/localhost.cnf', $tpl->grab());
1369+
unset($tpl);
1370+
// Generate new key, csr and cert
1371+
exec("(cd /etc/metronome/certs && make localhost.key)");
1372+
exec("(cd /etc/metronome/certs && make localhost.csr)");
1373+
exec("(cd /etc/metronome/certs && make localhost.cert)");
1374+
exec('chmod 0400 /etc/metronome/certs/localhost.key');
1375+
exec('chown metronome /etc/metronome/certs/localhost.key');
13521376

13531377
// Copy init script
13541378
caselog('cp -f apps/metronome-init /etc/init.d/metronome', __FILE__, __LINE__);
13551379
caselog('chmod u+x /etc/init.d/metronome', __FILE__, __LINE__);
13561380

13571381
exec($this->getinitcommand('xmpp', 'restart'));
13581382

1359-
1383+
/*
1384+
writing new private key to 'smtpd.key'
1385+
-----
1386+
You are about to be asked to enter information that will be incorporated
1387+
into your certificate request.
1388+
What you are about to enter is what is called a Distinguished Name or a DN.
1389+
There are quite a few fields but you can leave some blank
1390+
For some fields there will be a default value,
1391+
If you enter '.', the field will be left blank.
1392+
-----
1393+
Country Name (2 letter code) [AU]:
1394+
State or Province Name (full name) [Some-State]:
1395+
Locality Name (eg, city) []:
1396+
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
1397+
Organizational Unit Name (eg, section) []:
1398+
Common Name (e.g. server FQDN or YOUR name) []:
1399+
Email Address []:
1400+
* */
13601401

13611402
/*// Dont just copy over the virtualhost template but add some custom settings
13621403
$tpl = new tpl('apache_apps.vhost.master');
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
oid_section = new_oids
2+
3+
[ new_oids ]
4+
5+
# RFC 3920 section 5.1.1 defines this OID
6+
xmppAddr = 1.3.6.1.5.5.7.8.5
7+
8+
# RFC 4985 defines this OID
9+
SRVName = 1.3.6.1.5.5.7.8.7
10+
11+
[ req ]
12+
13+
default_bits = 4096
14+
default_keyfile = {tmpl_var name='domain'}.key
15+
distinguished_name = distinguished_name
16+
req_extensions = v3_extensions
17+
x509_extensions = v3_extensions
18+
19+
# ask about the DN?
20+
prompt = no
21+
22+
[ distinguished_name ]
23+
24+
commonName = {tmpl_var name='domain'}
25+
countryName = {tmpl_var name='ssl_country'}
26+
localityName = {tmpl_var name='ssl_locality'}
27+
organizationName = {tmpl_var name='ssl_organisation'}
28+
organizationalUnitName = {tmpl_var name='ssl_organisation_unit'}
29+
emailAddress = {tmpl_var name='ssl_email'}
30+
31+
[ v3_extensions ]
32+
33+
# for certificate requests (req_extensions)
34+
# and self-signed certificates (x509_extensions)
35+
36+
basicConstraints = CA:FALSE
37+
keyUsage = digitalSignature,keyEncipherment
38+
extendedKeyUsage = serverAuth,clientAuth
39+
subjectAltName = @subject_alternative_name
40+
41+
[ subject_alternative_name ]
42+
43+
# See http://tools.ietf.org/html/draft-ietf-xmpp-3920bis#section-13.7.1.2 for more info.
44+
45+
DNS.0 = {tmpl_var name='domain'}
46+
otherName.0 = xmppAddr;FORMAT:UTF8,UTF8:{tmpl_var name='domain'}
47+
otherName.1 = SRVName;IA5STRING:_xmpp-client.{tmpl_var name='domain'}
48+
otherName.2 = SRVName;IA5STRING:_xmpp-server.{tmpl_var name='domain'}

0 commit comments

Comments
 (0)