Debian Codegraph @

debian/proftpd-gencert

raw symbols SCIP
1 #!/bin/sh
2 #
3 # This script (re)creates a self-signed SSL certificate to be used for FTP/SSL protocol.
4 #
5 # Copyright (C) Francesco P. Lovergine <[email protected]>
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 2,
9 # as published by the Free Software Foundation.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #
20
21 DAYS=365
22 BITS=2048
23 KEYDIR=/etc/ssl/private
24 CERTDIR=/etc/ssl/certs
25 KEY=$KEYDIR/proftpd.key
26 CERT=$CERTDIR/proftpd.crt
27
28 if [ ! -x /usr/bin/openssl ]; then
29 echo "Openssl utility not found"
30 exit 1
31 fi
32
33 if [ $(id -u) -ne 0 ]; then
34 echo "Run this script as root"
35 exit 2
36 fi
37
38 if [ ! -d $KEYDIR -o ! -d $CERTDIR ]; then
39 echo "Target dirs not found"
40 exit 3
41 fi
42
43 rm -f $KEY $CERT
44 /usr/bin/openssl req -x509 -newkey rsa:$BITS \
45 -keyout $KEY -out $CERT \
46 -nodes -days $DAYS
47 if [ $? -eq 0 ]; then
48 chmod 0600 $KEY
49 chmod 0644 $CERT
50 cat <<EOF
51
52 Use the following information in your ProFTPD configuration:
53
54 TLSRSACertificateFile $CERT
55 TLSRSACertificateKeyFile $KEY
56
57 See /etc/proftpd/tls.conf for suggested TLS related configuration
58 items and include that file in your /etc/proftpd/proftpd.conf file.
59
60 EOF
61 else
62 echo "Key generation failed"
63 exit 4
64 fi
65
66 exit 0