add cert generator scripts, arrange scripts dir
This commit is contained in:
22
scripts/certs/client/gen.sh
Executable file
22
scripts/certs/client/gen.sh
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
rm -f client.key
|
||||||
|
rm -f client.crt
|
||||||
|
rm -f client.csr
|
||||||
|
rm -f client.p12
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
read -s pass
|
||||||
|
else
|
||||||
|
pass=$1
|
||||||
|
fi
|
||||||
|
subj="/C=BG/ST=Bulgaria/L=Sofia/O=S.M.I.I.R.K.Y./CN=localhost"
|
||||||
|
|
||||||
|
openssl genrsa -out client.key 4096
|
||||||
|
openssl req -new -key client.key -subj $subj -out client.csr
|
||||||
|
openssl x509 -req -days 365 -in client.csr -CA ../ca.crt -CAkey ../ca.key -set_serial 01 -out client.crt -passin pass:$pass
|
||||||
|
openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.p12 -password pass:$pass
|
||||||
|
openssl pkcs12 -in client.p12 -out client.pem -nodes -clcerts -password pass:$pass
|
||||||
|
|
||||||
17
scripts/certs/gen-ca.sh
Executable file
17
scripts/certs/gen-ca.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
rm -f ca.crt
|
||||||
|
rm -f ca.key
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
read -s pass
|
||||||
|
else
|
||||||
|
pass=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
subj="/C=BG/ST=Bulgaria/L=Sofia/O=S.M.I.R.K.Y./CN=localhost"
|
||||||
|
openssl genrsa -des3 -out ca.key -passout pass:$pass 4096
|
||||||
|
openssl req -new -x509 -days 365 -key ca.key -subj $subj -passin pass:$pass -out ca.crt -passin pass:$pass
|
||||||
|
|
||||||
40
scripts/certs/regen-all.sh
Executable file
40
scripts/certs/regen-all.sh
Executable file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
printf "Enter CA pass: "
|
||||||
|
read -s pass
|
||||||
|
printf "\n"
|
||||||
|
else
|
||||||
|
pass=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
cd "$DIR"
|
||||||
|
printf "${RED}Phase 1${NC} - Generating CA...\n"
|
||||||
|
out=$(./gen-ca.sh $pass 2>&1)
|
||||||
|
if [[ $out == *error* ]]; then
|
||||||
|
printf "%s\n" "$out"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "${RED}Phase 2${NC} - Generating server cert and key...\n"
|
||||||
|
cd server
|
||||||
|
out=$(./gen.sh $pass 2>&1)
|
||||||
|
if [[ $out == *error* ]]; then
|
||||||
|
printf "%s\n" "$out"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "${RED}Phase 3${NC} - Generating client cert and key...\n"
|
||||||
|
cd ../client
|
||||||
|
out="$(./gen.sh $pass 2>&1)"
|
||||||
|
if [[ $out == *error* ]]; then
|
||||||
|
printf "%s\n" "$out"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "${GREEN}Done!${NC}\n"
|
||||||
|
|
||||||
|
chmod -R +r "$DIR"
|
||||||
|
|
||||||
25
scripts/certs/server/gen.sh
Executable file
25
scripts/certs/server/gen.sh
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
rm -f server.key
|
||||||
|
rm -f server.crt
|
||||||
|
rm -f server.csr
|
||||||
|
rm -f server.p12
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
printf "Enter CA pass: "
|
||||||
|
read -s pass
|
||||||
|
printf "\n"
|
||||||
|
else
|
||||||
|
pass=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
subj="/C=BG/ST=Bulgaria/L=Sofia/O=S.M.I.I.R.K.Y./CN=localhost"
|
||||||
|
|
||||||
|
openssl genrsa -out server.key 4096
|
||||||
|
openssl req -new -key server.key -subj $subj -out server.csr
|
||||||
|
openssl x509 -req -days 365 -in server.csr -CA ../ca.crt -CAkey ../ca.key -set_serial 01 -out server.crt -passin pass:$pass
|
||||||
|
openssl pkcs12 -export -clcerts -in server.crt -inkey server.key -out server.p12 -password pass:$pass
|
||||||
|
openssl pkcs12 -in server.p12 -out server.pem -nodes -clcerts -password pass:$pass
|
||||||
|
|
||||||
Reference in New Issue
Block a user