blob: 8eb471fb4b15d9a2edf0065703fe6ef4cd25a202 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#! /bin/sh
# $Header: /var/cvsroot/gentoo-x86/mail-mta/qmail-ldap/files/1.03-r4/mkservercert,v 1.1 2004/05/30 10:52:45 robbat2 Exp $
# Self-signed certificate generator for Qmail under Gentoo
# Robin H. Johnson <robbat2@gentoo.org> - October 17, 2003
# Based on mkimapdcert from courier-imap.
test -x /usr/bin/openssl || exit 0
source /sbin/functions.sh
filedir="/var/qmail/control"
pemfile="${filedir}/servercert.pem"
randfile="${filedir}/servercert.rand"
conffile="${filedir}/servercert.cnf"
# file details for pemfile
mode="0640"
uid="qmaild"
gid="qmail"
# expire on certifcate
days="365"
if test -f $pemfile
then
eerror "$pemfile already exists."
exit 1
fi
ewarn "Please customize ${conffile} before continuing!"
einfo "Press ENTER to continue, or CTRL-C to stop now."
read
# setup the temp file
cp /dev/null $pemfile
chmod 600 $pemfile
chown root $pemfile
cleanup() {
rm -f $pemfile
rm -f $randfile
exit 1
}
dd if=/dev/urandom of=${randfile} bs=64 count=1 2>/dev/null
chmod 600 ${randfile}
einfo "Creating self-signed certificate"
/usr/bin/openssl req -new -x509 -days ${days} -nodes \
-config ${conffile} -out $pemfile -keyout $pemfile -rand ${randfile} || cleanup
einfo "Certificate details"
/usr/bin/openssl x509 -subject -dates -fingerprint -noout -in $pemfile || cleanup
chown ${uid}:${gid} ${pemfile}
chmod ${mode} ${pemfile}
#qmail needs an extra item
ln -s ${pemfile} ${filedir}/clientcert.pem
rm -f $randfile
|