/usr/lib/courier/mkcouriercert is in courier-base 0.76.3-5+deb9u1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | #! /bin/sh
#
#
# Copyright 2000-2007 Double Precision, Inc. See COPYING for
# distribution information.
#
# This is a short script to q`uickly generate a self-signed X.509 key for
# STARTTLS. Normally this script would get called by an automatic
# package installation routine.
CERTNAME=$(basename $0 | sed -e 's/^mk//;s/cert$//')
PEMFILE="$1"
if [ -z "$PEMFILE" ]; then
PEMFILE=/etc/courier/$CERTNAME.pem
fi
KEYFILE="$PEMFILE.key"
CERTFILE="$PEMFILE.cert"
RANDFILE="$PEMFILE.rand"
if test "gnutls" = "openssl"
then
test -x /usr/bin/openssl || exit 0
else
test -x /usr/bin/certtool || exit 0
fi
if test -f "$PEMFILE"
then
echo "$PEMFILE already exists."
exit 1
fi
cleanup() {
rm -f "$PEMFILE"
rm -f "$KEYFILE"
rm -f "$CERTFILE"
rm -f "$RANDFILE"
exit 1
}
cd /etc/courier
umask 077
BITS="$BITS"
set -e
install -b -m 600 -o "courier" /dev/null "$PEMFILE"
if test "gnutls" = "openssl"
then
dd if=/dev/urandom of="$RANDFILE" count=1 2>/dev/null
/usr/bin/openssl req -new -x509 -days 365 -nodes \
-config "/etc/courier/$CERTNAME.cnf" -out "$PEMFILE" -keyout "$PEMFILE" || cleanup
/usr/bin/openssl dhparam -2 -rand "$RANDFILE" 512 >>"$PEMFILE" || cleanup
/usr/bin/openssl x509 -subject -dates -fingerprint -noout -in "$PEMFILE" || cleanup
rm -f "$RANDFILE"
else
if test "$BITS" = ""
then
BITS="high"
fi
install -b -m 600 -o "courier" /dev/null "$KEYFILE"
install -v -m 600 -o "courier" /dev/null "$CERTFILE"
/usr/bin/certtool --generate-privkey --sec-param=$BITS --outfile "$KEYFILE"
/usr/bin/certtool --generate-self-signed --load-privkey "$KEYFILE" --outfile "$CERTFILE" --template "/etc/courier/$CERTNAME.cnf"
cat "$KEYFILE" "$CERTFILE" > "$PEMFILE"
rm -f "$KEYFILE" "$CERTFILE"
fi
|