ding/2_generateServCert.sh

74 lines
1.2 KiB
Bash
Raw Normal View History

2017-09-30 12:51:23 +00:00
#!/bin/bash
## Server private key
2018-03-28 22:58:36 +00:00
echo -n "Where to save your server's key file? ($PWD/dingd.key): "
2017-09-30 12:51:23 +00:00
read temp
if [ -n "$temp" ]
then
save=$temp
else
2018-03-28 22:58:36 +00:00
save="$PWD/dingd.key"
2017-09-30 12:51:23 +00:00
fi
key=$save
openssl genrsa -out $save 4096
## CSR
2018-03-28 22:58:36 +00:00
echo -n "Where to save your Certificate Signing Request (CSR)? ($PWD/dingd.csr): "
2017-09-30 12:51:23 +00:00
read temp
if [ -n "$temp" ]
then
save=$temp
else
2018-03-28 22:58:36 +00:00
save="$PWD/dingd.csr"
2017-09-30 12:51:23 +00:00
fi
csr=$save
echo -e "\033[01;33mPlease enter some information. THEY MUST BE DIFFERENT FROM THE CA's INFORMATION.\033[00m"
openssl req -new -key $key -out $save -sha512
## Signing
echo -n "Path of your CA Certificate? ($PWD/CA.crt): "
read temp
if [ -n "$temp" ]
then
loadCAcrt=$temp
else
loadCAcrt="$PWD/CA.crt"
fi
echo -n "Path of your CA key? ($PWD/CA.key): "
read temp
if [ -n "$temp" ]
then
loadCAkey=$temp
else
loadCAkey="$PWD/CA.key"
fi
2018-03-28 22:58:36 +00:00
echo -n "Where to save your signed server certificate? ($PWD/dingd.crt): "
2017-09-30 12:51:23 +00:00
read temp
if [ -n "$temp" ]
then
save=$temp
else
2018-03-28 22:58:36 +00:00
save="$PWD/dingd.crt"
2017-09-30 12:51:23 +00:00
fi
echo -n "How many days should the certificate be valid? (365): "
read temp
if [ -n "$temp" ]
then
t=$temp
else
t=365
fi
openssl x509 -req -in $csr -CA $loadCAcrt -CAkey $loadCAkey -CAcreateserial -out $save -days $t -sha512
rm $csr