Import Debian changes 4.92-8+deb10u4
[hcoop/debian/exim4.git] / debian / exim-gencert
CommitLineData
de45f55a
AM
1#!/bin/sh -e
2
3if [ -n "$EX4DEBUG" ]; then
4 echo "now debugging $0 $@"
5 set -x
6fi
7
8DIR=/etc/exim4
9CERT=$DIR/exim.crt
10KEY=$DIR/exim.key
11
12# This exim binary was built with GnuTLS which does not support dhparams
13# from a file. See /usr/share/doc/exim4-base/README.Debian.gz
14#DH=$DIR/exim.dhparam
15
16if ! which openssl > /dev/null ;then
17 echo "$0: openssl is not installed, exiting" 1>&2
18 exit 1
19fi
20
21# valid for three years
22DAYS=1095
23
24if [ "$1" != "--force" ] && [ -f $CERT ] && [ -f $KEY ]; then
25 echo "[*] $CERT and $KEY exists!"
26 echo " Use \"$0 --force\" to force generation!"
27 exit 0
28fi
29
30if [ "$1" = "--force" ]; then
31 shift
32fi
33
34#SSLEAY=/tmp/exim.ssleay.$$.cnf
35SSLEAY="$(tempfile -m600 -pexi)"
36
37cat > $SSLEAY <<EOM
38RANDFILE = $HOME/.rnd
39[ req ]
40default_bits = 2048
41default_keyfile = exim.key
42distinguished_name = req_distinguished_name
43[ req_distinguished_name ]
44countryName = Country Code (2 letters)
45countryName_default = US
46countryName_min = 2
47countryName_max = 2
48stateOrProvinceName = State or Province Name (full name)
49localityName = Locality Name (eg, city)
50organizationName = Organization Name (eg, company; recommended)
51organizationName_max = 64
52organizationalUnitName = Organizational Unit Name (eg, section)
53organizationalUnitName_max = 64
54commonName = Server name (eg. ssl.domain.tld; required!!!)
55commonName_max = 64
56emailAddress = Email Address
57emailAddress_max = 40
58EOM
59
60echo "[*] Creating a self signed SSL certificate for Exim!"
61echo " This may be sufficient to establish encrypted connections but for"
62echo " secure identification you need to buy a real certificate!"
63echo " "
64echo " Please enter the hostname of your MTA at the Common Name (CN) prompt!"
65echo " "
66
67openssl req -config $SSLEAY -x509 -newkey rsa:2048 -keyout $KEY -out $CERT -days $DAYS -nodes
68#see README.Debian.gz*# openssl dhparam -check -text -5 512 -out $DH
69rm -f $SSLEAY
70
71chown root:Debian-exim $KEY $CERT $DH
72chmod 640 $KEY $CERT $DH
73
74echo "[*] Done generating self signed certificates for exim!"
75echo " Refer to the documentation and example configuration files"
76echo " over at /usr/share/doc/exim4-base/ for an idea on how to enable TLS"
77echo " support in your mail transfer agent."
78