Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2748 - (hide annotations) (download)
Fri Jan 29 12:32:15 2016 UTC (8 years, 3 months ago) by niro
File size: 1051 byte(s)
-use sha1 as signature algorithm to support sslsvd
1 niro 1248 #!/bin/bash
2    
3     die() { echo "Error: $@"; exit 1; }
4    
5     usage()
6     {
7 niro 2745 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 niro 1248 }
14    
15 niro 2134 SSLDIR="${SSLDIR-@@SSLDIR@@}"
16 niro 1248 SSLCONFIG="${SSLCONFIG-${SSLDIR}/openssl.cnf}"
17     CERTDIR="${SSLDIR}/certs"
18     KEYDIR="${SSLDIR}/private"
19 niro 2746 CERTNAME="mcored"
20 niro 1248 CERTFILE="${CERTDIR}/${CERTNAME}.pem"
21     KEYFILE="${KEYDIR}/${CERTNAME}.key"
22    
23 niro 2745 type -P openssl > /dev/null || die "openssl not found!"
24     [[ $(id -u) -ne 0 ]] && die "You must be root!"
25     [ ! -d ${CERTDIR} ] && die "${CERTDIR} directory doesn't exist!"
26     [ ! -d ${KEYDIR} ] && die "${KEYDIR} directory doesn't exist!"
27     [ -f ${CERTFILE} ] && die "${CERTFILE} already exists, won't overwrite!"
28     [ -f ${KEYFILE} ] && die "${KEYFILE} already exists, won't overwrite!"
29    
30 niro 2748 openssl req -new -x509 -sha1 -nodes -config ${SSLCONFIG} -out ${CERTFILE} -keyout ${KEYFILE} -days 365 || die "Certificate request failed!"
31     openssl x509 -sha1 -subject -fingerprint -noout -in ${CERTFILE} || die "Fingerprint failed!"