]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/scripts/httpscert
3 # new : generate new certificate
4 # read: read issuer in certificate and verify if it is the same as hostname
6 # See how we were called.
9 # set temporary random file
10 export RANDFILE
=/root
/.rnd
11 if [ ! -f /etc
/httpd
/server.key
]; then
12 echo "Generating https server key."
13 /usr
/bin
/openssl genrsa
-rand \
14 /boot
/vmlinuz
:CONFIG_ROOT
/ethernet
/settings
-out \
15 /etc
/httpd
/server.key
1024
18 /bin
/cat /etc
/certparams |
sed "s/HOSTNAME/`hostname -f`/" |
/usr
/bin
/openssl \
19 req
-new -key /etc
/httpd
/server.key
-out /etc
/httpd
/server.csr
20 echo "Signing certificate"
21 /usr
/bin
/openssl x509
-req -days 999999 -in \
22 /etc
/httpd
/server.csr
-signkey /etc
/httpd
/server.key
-out \
24 # unset and remove random file
29 if [ -f /etc
/httpd
/server.key
-a -f /etc
/httpd
/server.crt
-a -f /etc
/httpd
/server.csr
]; then
30 ISSUER
=`openssl x509 -in /etc/httpd/server.crt -text -noout | grep Issuer | /usr/bin/cut -f2 -d '='`
31 HOSTNAME
=`/bin/hostname -f`
32 if [ "$ISSUER" != "$HOSTNAME" ]; then
33 echo "Certificate issuer '$ISSUER' is not the same as the hostname '$HOSTNAME'"
34 echo "Probably host or domain name has been changed in setup"
35 echo "You could remake server certificate with '/usr/local/bin/httpscert new'"
38 echo "https certificate issuer match $HOSTNAME"
41 echo "Certificate not found"
46 /bin
/echo "Usage: $0 {read|new}"