2015-01-24 08:15:27 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
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
|
|
|
|
PREF=$2
|
2015-01-24 11:05:54 +01:00
|
|
|
|
|
|
|
#if [ ! -z $2 ]
|
|
|
|
#then
|
|
|
|
# PREF=""
|
|
|
|
#fi
|
|
|
|
|
|
|
|
|
2015-02-01 13:35:52 +01:00
|
|
|
SUBJ="/C=DE/ST=Berlin/L=Berlin/O=Cauwersin/CN=C1130-c80aa9cd7fa4/emailAddress=7u83@mail.ru"
|
2015-01-24 11:05:54 +01:00
|
|
|
if [ "$PREF" = "cisco" ]
|
2015-01-24 08:15:27 +01:00
|
|
|
then
|
|
|
|
PREF="$2-"
|
|
|
|
SUBJ="/C=US/ST=California/L=San Jose/O=Cisco Virtual Wireless LAN Controller/CN=DEVICE-AC-TUBE/emailAddress=7u83@mail.ru"
|
|
|
|
fi
|
|
|
|
|
2015-02-01 13:35:52 +01:00
|
|
|
if [ "$PREF" = "simple" ]
|
|
|
|
then
|
|
|
|
PREF="$2"
|
|
|
|
SUBJ="/C=DE/ST=Berlin/L=Berlin/O=Cauwersin/CN=C1130-908d43460000/mailAddress=7u83@mail.ru"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$PREF" = "cisco-ap" ]
|
|
|
|
then
|
|
|
|
PREF="$2-"
|
|
|
|
# SUBJ="/C=US/ST=California/L=San Jose/O=Cisco Systems/CN=C1130-f866f2a342fc/emailAddress=support@cisco.com"
|
|
|
|
# SUBJ="/C=US/ST=California/L=San Jose/O=airespace Inc/CN=C1130-f866f2a342fc/emailAddress=support@airespace.com"
|
|
|
|
|
|
|
|
# SUBJ="/ST=California/L=San Jose/C=US/O=Cisco Systems/CN=C1130-c80aa9cd7fa4/emailAddress=support@cisco.com"
|
|
|
|
#SUBJ="/ST=California/L=San Jose/C=US/O=Cisco Systems/CN=C1130-c80aa9cd7fa4/emailAddress=support@cisco.com"
|
|
|
|
# SUBJ="/C=US/ST=California/L=San Jose/O=airespace Inc/CN=C1130-f866f2a342fc/emailAddress=support@airespace.com"
|
|
|
|
SUBJ="/C=US/ST=California/L=San Jose/O=Cisco Systems/CN=C1130-c80aa9cd7fa4/emailAddress=support@cisco.com"
|
|
|
|
# SUBJ="/C=US/ST=California/L=San Jose/O=Cisco Systems/CN=C1200-c80aa9cd7fa4/emailAddress=support@cisco.com"
|
2015-01-24 08:15:27 +01:00
|
|
|
|
|
|
|
|
2015-02-01 13:35:52 +01:00
|
|
|
fi
|
|
|
|
|
2015-01-24 11:05:54 +01:00
|
|
|
|
2015-01-24 08:15:27 +01:00
|
|
|
DIR=./certs
|
|
|
|
ROOT_CA_DIR=./root-ca
|
|
|
|
INT_CA_DIR=./intermediate-ca
|
|
|
|
|
|
|
|
echo $NAME
|
|
|
|
|
|
|
|
if [ ! -e $DIR ]
|
|
|
|
then
|
|
|
|
mkdir $DIR
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2015-02-01 13:35:52 +01:00
|
|
|
$OPENSSL req -nodes -newkey rsa:$KEYSIZE -keyout $DIR/$NAME.key -out $DIR/$NAME.req \
|
2015-01-24 08:15:27 +01:00
|
|
|
-subj "$SUBJ"
|
|
|
|
|
2015-02-01 13:35:52 +01:00
|
|
|
if [ "$2" = "simple" ]
|
2015-01-24 11:05:54 +01:00
|
|
|
then
|
2015-02-01 13:35:52 +01:00
|
|
|
$OPENSSL ca -config openssl-simple.cnf \
|
2015-01-24 11:05:54 +01:00
|
|
|
-keyfile $ROOT_CA_DIR/${PREF}-root-ca.key \
|
|
|
|
-cert $ROOT_CA_DIR/${PREF}-root-ca.crt \
|
|
|
|
-batch \
|
|
|
|
-out $DIR/$NAME.crt -infiles $DIR/$NAME.req
|
|
|
|
|
2015-02-01 13:35:52 +01:00
|
|
|
$OPENSSL x509 -in $DIR/$NAME.crt -out $DIR/$NAME.pem
|
|
|
|
|
|
|
|
elif [ "$2" = "nocisco-ap" ]
|
|
|
|
then
|
|
|
|
$OPENSSL ca -config openssl-simple.cnf \
|
|
|
|
-keyfile $ROOT_CA_DIR/${PREF}root-ca.key \
|
|
|
|
-cert $ROOT_CA_DIR/${PREF}root-ca.crt \
|
|
|
|
-batch \
|
|
|
|
-out $DIR/$NAME.crt -infiles $DIR/$NAME.req
|
|
|
|
|
|
|
|
$OPENSSL x509 -in $DIR/$NAME.crt -out $DIR/$NAME.pem
|
|
|
|
|
2015-01-24 17:07:20 +01:00
|
|
|
|
2015-01-24 11:05:54 +01:00
|
|
|
else
|
2015-02-01 13:35:52 +01:00
|
|
|
$OPENSSL ca -config openssl-int.cnf \
|
2015-01-24 08:15:27 +01:00
|
|
|
-keyfile $INT_CA_DIR/${PREF}int-ca.key \
|
|
|
|
-cert $INT_CA_DIR/${PREF}int-ca.crt \
|
|
|
|
-batch \
|
|
|
|
-out $DIR/$NAME.crt -infiles $DIR/$NAME.req
|
2015-01-24 17:07:20 +01:00
|
|
|
|
|
|
|
|
2015-02-01 13:35:52 +01:00
|
|
|
$OPENSSL x509 -in $DIR/$NAME.crt -out $DIR/$NAME.pem
|
2015-01-24 11:05:54 +01:00
|
|
|
cat $INT_CA_DIR/${PREF}int-ca.crt >> $DIR/$NAME.pem
|
|
|
|
cat $ROOT_CA_DIR/${PREF}root-ca.crt >> $DIR/$NAME.pem
|
2015-02-01 13:35:52 +01:00
|
|
|
$OPENSSL x509 -in $INT_CA_DIR/${PREF}int-ca.crt -noout -sha1 -fingerprint
|
|
|
|
|
2015-01-24 11:05:54 +01:00
|
|
|
fi
|
2015-01-24 08:15:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|