Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/daemon/generate-certificate.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2134 - (hide annotations) (download)
Fri Jan 10 10:10:38 2014 UTC (10 years, 4 months ago) by niro
File size: 1085 byte(s)
-variable pathes
1 niro 1248 #!/bin/bash
2    
3     die() { echo "Error: $@"; exit 1; }
4    
5     usage()
6     {
7     echo "Usage:"
8     echo " $0"
9     echo
10     echo "The environment variables \$SSLCONFIG and \$SSLDIR will be respected too."
11     echo
12     die "No certificate name given!"
13     }
14    
15 niro 2124 type -P openssl > /dev/null || die "openssl not found!"
16 niro 1248 [[ $(id -u) -ne 0 ]] && die "You must be root!"
17     [ ! -d ${CERTDIR} ] && die "${CERTDIR} directory doesn't exist!"
18     [ ! -d ${KEYDIR} ] && die "${KEYDIR} directory doesn't exist!"
19     [ -f ${CERTFILE} ] && die "${CERTFILE} already exists, won't overwrite!"
20     [ -f ${KEYFILE} ] && die "${KEYFILE} already exists, won't overwrite!"
21    
22 niro 2134 SSLDIR="${SSLDIR-@@SSLDIR@@}"
23 niro 1248 SSLCONFIG="${SSLCONFIG-${SSLDIR}/openssl.cnf}"
24     CERTDIR="${SSLDIR}/certs"
25     KEYDIR="${SSLDIR}/private"
26     CERTNAME="mcore"
27     CERTFILE="${CERTDIR}/${CERTNAME}.pem"
28     KEYFILE="${KEYDIR}/${CERTNAME}.key"
29    
30     openssl req -new -x509 -nodes -config ${SSLCONFIG} -out ${CERTFILE} -keyout ${KEYFILE} -days 365 || die "Certificate request failed!"
31     openssl x509 -subject -fingerprint -noout -in ${CERTFILE} || die "Fingerprint failed!"