2016-08-27 01:03:02 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2016-08-27 01:06:48 +02:00
|
|
|
|
|
|
|
export OPENSSL_CONF="./CAtsa.cnf"
|
|
|
|
|
2016-08-27 01:27:15 +02:00
|
|
|
cd `dirname $0`
|
|
|
|
|
2016-08-27 01:03:02 +02:00
|
|
|
error () {
|
|
|
|
|
|
|
|
echo "TSA test failed!" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
create_ca () {
|
|
|
|
|
|
|
|
echo "Creating a new CA for the TSA tests..."
|
|
|
|
TSDNSECT=ts_ca_dn
|
|
|
|
export TSDNSECT
|
|
|
|
openssl req -new -x509 -nodes \
|
|
|
|
-out tsaca.pem -keyout tsacakey.pem
|
|
|
|
test $? != 0 && error
|
|
|
|
}
|
|
|
|
|
|
|
|
create_tsa_cert () {
|
|
|
|
|
|
|
|
INDEX=$1
|
|
|
|
export INDEX
|
|
|
|
EXT=$2
|
|
|
|
TSDNSECT=ts_cert_dn
|
2016-09-11 23:57:25 +02:00
|
|
|
export TSDNSECT
|
2016-08-27 01:03:02 +02:00
|
|
|
|
|
|
|
openssl req -new \
|
|
|
|
-out tsa_req${INDEX}.pem -keyout tsa_key${INDEX}.pem
|
|
|
|
test $? != 0 && error
|
|
|
|
echo Using extension $EXT
|
|
|
|
openssl x509 -req \
|
|
|
|
-in tsa_req${INDEX}.pem -out tsa_cert${INDEX}.pem \
|
|
|
|
-CA tsaca.pem -CAkey tsacakey.pem -CAcreateserial \
|
|
|
|
-extfile $OPENSSL_CONF -extensions $EXT
|
|
|
|
test $? != 0 && error
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:57:25 +02:00
|
|
|
create_cert () {
|
|
|
|
|
|
|
|
INDEX=$1
|
|
|
|
export INDEX
|
|
|
|
TSDNSECT=ts_cert_dn
|
|
|
|
export TSDNSECT
|
|
|
|
|
|
|
|
openssl req -new \
|
|
|
|
-out tsa_req${INDEX}.pem -keyout ssl_key${INDEX}.pem
|
|
|
|
test $? != 0 && error
|
|
|
|
openssl x509 -req \
|
|
|
|
-in tsa_req${INDEX}.pem -out ssl_cert${INDEX}.pem \
|
|
|
|
-CA tsaca.pem -CAkey tsacakey.pem -CAcreateserial \
|
|
|
|
-extensions server_cert
|
|
|
|
test $? != 0 && error
|
|
|
|
cat ssl_key${INDEX}.pem ssl_cert${INDEX}.pem >ssl_keycerts${INDEX}.pem
|
|
|
|
}
|
|
|
|
|
2016-08-27 01:03:02 +02:00
|
|
|
echo "Creating CA for TSA tests..."
|
|
|
|
create_ca
|
|
|
|
|
|
|
|
echo "Creating tsa_cert1.pem TSA server cert..."
|
|
|
|
create_tsa_cert 1 tsa_cert
|
|
|
|
|
2016-09-11 23:57:25 +02:00
|
|
|
echo "Creating tsa_cert2.pem TSA server cert..."
|
2016-09-07 21:45:48 +02:00
|
|
|
create_tsa_cert 2 tsa_cert
|
2016-08-27 01:03:02 +02:00
|
|
|
|
2016-09-11 23:57:25 +02:00
|
|
|
echo "Creating ssl_keycerts1.pem for ssl"
|
|
|
|
create_cert 1
|
|
|
|
|
2016-09-07 21:45:48 +02:00
|
|
|
exit 0
|