2020-03-07 09:34:33 +01:00
|
|
|
#!/bin/sh
|
2015-01-24 08:15:27 +01:00
|
|
|
|
|
|
|
KEYSIZE=2048
|
2015-02-01 13:35:52 +01:00
|
|
|
#OPENSSL="../src/contrib/openssl-1.0.1i/apps/openssl"
|
|
|
|
OPENSSL="openssl"
|
2015-01-24 08:15:27 +01:00
|
|
|
|
2015-02-01 13:35:52 +01:00
|
|
|
set -x
|
2015-01-24 08:15:27 +01:00
|
|
|
|
|
|
|
NAME=$1
|
2015-02-03 08:21:04 +01:00
|
|
|
TYPE=$2
|
2015-01-24 11:05:54 +01:00
|
|
|
|
2022-07-28 01:36:16 +02:00
|
|
|
DAYS=6000
|
2015-01-24 11:05:54 +01:00
|
|
|
|
2015-02-03 08:21:04 +01:00
|
|
|
DIR=./certs
|
|
|
|
ROOT_CA_DIR=./root-ca
|
|
|
|
INT_CA_DIR=./intermediate-ca
|
|
|
|
|
2015-01-24 08:15:27 +01:00
|
|
|
|
2015-02-03 08:21:04 +01:00
|
|
|
if [ ! -e $DIR ]
|
2015-02-01 13:35:52 +01:00
|
|
|
then
|
2015-02-03 08:21:04 +01:00
|
|
|
mkdir $DIR
|
2015-02-01 13:35:52 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2015-01-24 08:15:27 +01:00
|
|
|
|
2015-02-03 08:21:04 +01:00
|
|
|
createcert()
|
|
|
|
{
|
|
|
|
SUBJ=$1
|
|
|
|
CNF=$2
|
2015-01-24 08:15:27 +01:00
|
|
|
|
2015-02-01 13:35:52 +01:00
|
|
|
|
2015-02-03 08:21:04 +01:00
|
|
|
if [ ! -z $TYPE ]
|
|
|
|
then
|
|
|
|
PREF="$TYPE-"
|
|
|
|
fi
|
|
|
|
$OPENSSL genrsa -out $DIR/$NAME.key $KEYSIZE
|
2015-03-12 23:21:57 +01:00
|
|
|
$OPENSSL req -sha256 -new -key $DIR/$NAME.key -out $DIR/$NAME.req \
|
2015-02-03 08:21:04 +01:00
|
|
|
-subj "$SUBJ"
|
2015-01-24 11:05:54 +01:00
|
|
|
|
2015-01-24 08:15:27 +01:00
|
|
|
|
2016-03-01 09:31:16 +01:00
|
|
|
$OPENSSL ca -config openssl.cnf \
|
2015-02-03 08:21:04 +01:00
|
|
|
-keyfile $INT_CA_DIR/${PREF}int-ca.key \
|
|
|
|
-cert $INT_CA_DIR/${PREF}int-ca.crt \
|
|
|
|
-batch \
|
|
|
|
-extensions v3_ca \
|
|
|
|
-out $DIR/$NAME.crt -infiles $DIR/$NAME.req
|
2015-01-24 08:15:27 +01:00
|
|
|
|
2015-02-03 08:21:04 +01:00
|
|
|
$OPENSSL x509 -in $DIR/$NAME.crt -out $DIR/$NAME.pem
|
|
|
|
cat $INT_CA_DIR/${PREF}int-ca.crt >> $DIR/$NAME.pem
|
|
|
|
cat $ROOT_CA_DIR/${PREF}root-ca.crt >> $DIR/$NAME.pem
|
2015-02-09 22:04:54 +01:00
|
|
|
echo "Root finger print:"
|
|
|
|
$OPENSSL x509 -in $ROOT_CA_DIR/${PREF}root-ca.crt -noout -sha1 -fingerprint
|
|
|
|
echo "Int finger print:"
|
2015-02-03 08:21:04 +01:00
|
|
|
$OPENSSL x509 -in $INT_CA_DIR/${PREF}int-ca.crt -noout -sha1 -fingerprint
|
2015-02-09 22:04:54 +01:00
|
|
|
echo "Cert finger print:"
|
|
|
|
$OPENSSL x509 -in $DIR/${NAME}.crt -noout -sha1 -fingerprint
|
2015-01-24 08:15:27 +01:00
|
|
|
|
2015-02-03 08:21:04 +01:00
|
|
|
}
|
2015-01-24 08:15:27 +01:00
|
|
|
|
|
|
|
|
2015-02-03 08:21:04 +01:00
|
|
|
if [ -z $TYPE ]
|
2015-01-24 11:05:54 +01:00
|
|
|
then
|
2015-02-03 08:21:04 +01:00
|
|
|
SUBJ="/C=DE/ST=Berlin/L=Berlin/O=Cauwersin/CN=C1130-c80aa9cd7fa4/emailAddress=7u83@mail.ru"
|
|
|
|
createcert $SUBJ
|
|
|
|
fi
|
2015-02-01 13:35:52 +01:00
|
|
|
|
2022-07-11 08:26:56 +02:00
|
|
|
|
2015-02-03 08:21:04 +01:00
|
|
|
if [ "$TYPE" = "cisco-ac" ]
|
2015-02-01 13:35:52 +01:00
|
|
|
then
|
2015-02-03 08:21:04 +01:00
|
|
|
SUBJ="/C=US/ST=California/L=San Jose/O=Cisco Virtual Wireless LAN Controller/CN=DEVICE-AC-TUBE/emailAddress=7u83@mail.ru"
|
2015-02-06 21:12:30 +01:00
|
|
|
createcert "$SUBJ"
|
2015-02-03 08:21:04 +01:00
|
|
|
fi
|
2015-01-24 17:07:20 +01:00
|
|
|
|
|
|
|
|
2015-02-03 08:21:04 +01:00
|
|
|
if [ "$TYPE" = "cisco-ap" ]
|
|
|
|
then
|
|
|
|
PREF="$2-"
|
2020-03-08 23:00:54 +01:00
|
|
|
SUBJ="/C=US/ST=California/L=San Jose/O=Cisco Systems/CN=C1130-0800276edf58/emailAddress=support@cisco.com"
|
2015-03-12 23:21:57 +01:00
|
|
|
|
|
|
|
openssl req -nodes -new -x509 \
|
|
|
|
-sha1 \
|
|
|
|
-extensions v3_ca \
|
2022-07-28 01:36:16 +02:00
|
|
|
-days ${DAYS} \
|
|
|
|
-newkey rsa:${KEYSIZE} \
|
2015-03-12 23:21:57 +01:00
|
|
|
-keyout certs/${NAME}.key -out certs/${NAME}.crt \
|
|
|
|
-config openssl.cnf \
|
|
|
|
-x509 \
|
2022-07-11 08:26:56 +02:00
|
|
|
-subj "$SUBJ"
|
2015-03-12 23:21:57 +01:00
|
|
|
|
2022-07-28 01:36:16 +02:00
|
|
|
$OPENSSL x509 -in $DIR/$NAME.crt -out $DIR/$NAME.pem -days=${DAYS}
|
2015-03-12 23:21:57 +01:00
|
|
|
|
2015-02-01 13:35:52 +01:00
|
|
|
|
2015-01-24 08:15:27 +01:00
|
|
|
|
2015-02-03 08:21:04 +01:00
|
|
|
fi
|
2015-01-24 08:15:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|